Date: Fri, 30 Aug 1996 12:46:34 -0700 (PDT) From: Archie Cobbs <archie@whistle.com> To: freebsd-hackers@freebsd.org Subject: killproc program Message-ID: <199608301946.MAA03476@bubba.whistle.com>
next in thread | raw e-mail | index | archive | help
I finally got around to writing a little program that I've needed for
a while, a "killproc" to kill process(es) by name, PID, or pid file.
Similar to "killall" which I used to use under Linux.. this is especially
useful in scripts that need to kill and restart things like sendmail
that store their process ID's in a file, or for general sysadmin type
maintenance.
I figured somebody else might be looking for the same thing, so... the
man page is below .. is there any interest in putting this somewhere
on ftp.freebsd.org? If not, send me email for a tarball.
-Archie
___________________________________________________________________________
Archie L. Cobbs, archie@whistle.com * Whistle Communications Corporation
KILLPROC(1) FreeBSD Reference Manual KILLPROC(1)
NAME
killproc - kill a system daemon
SYNOPSIS
killproc [-ka] [-p pid] [-f pid-file] [-s signal] [-i interval] [-m
max-wait] [procname ...]
DESCRIPTION
killproc is used to reliably kill a process or set of processes. The
process ID can be specified explicitly on the command line, or implicitly
via a filename (from which the process ID is read), or by the name of the
process. killproc sends SIGTERM, or another signal specified on the com-
mand line, to the process and waits for it to die before exiting. If the
process fails to exit, the signal is resent at fixed intervals up to some
maximum time, at which time killproc then sends a SIGKILL or just gives
up.
killproc requires the proc filesystem to be mounted on /proc.
OPTIONS
The following flags are interpreted by killproc.
-p pid Kill the process with process ID pid. If a name is given on
the command line, verify the name of the process before
killing it.
-f pid-file Read the process ID from the file pid-file. If a name is
given on the command line, verify the name of the process
before killing it.
-s signal Send signal instead of SIGTERM. The signal may be a name or
a number.
-i interval Pause interval seconds after sending each signal. The de-
fault is one second.
-m max-wait Wait up to max-wait seconds for the process to die before
giving up or sending SIGKILL. If max-wait is zero, wait in-
definitely. The default is ten seconds.
-a When one or more process names is given, kill all instances
of each process, rather than just the first one found.
-k After the time limit has been reached, send a SIGKILL to the
process instead of just giving up.
EXIT VALUES
killproc returns zero if all processes have either exited or been sent a
SIGKILL, or if there was nothing to do; otherwise, one is returned.
It is an error to specify more than one process name when either the -f
or -p flags is used.
BUGS
The -a flag can cause an infinite loop if some other process is respawing
the target process (even if it's a parent process with the same name).
It is possible for a process to not die after receiving a SIGKILL signal
if, for example, it is stuck in an uninterruptable sleep. This usually
indicates a serious system problem.
AUTHOR
Archie Cobbs <archie@whistle.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199608301946.MAA03476>
