From owner-freebsd-hackers Fri Aug 30 12:47:36 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id MAA16017 for hackers-outgoing; Fri, 30 Aug 1996 12:47:36 -0700 (PDT) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id MAA16012 for ; Fri, 30 Aug 1996 12:47:31 -0700 (PDT) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id MAA08857; Fri, 30 Aug 1996 12:46:54 -0700 (PDT) Received: from bubba.whistle.com(207.76.205.7) by whistle.com via smap (V1.3) id sma008855; Fri Aug 30 12:46:36 1996 Received: (from archie@localhost) by bubba.whistle.com (8.6.12/8.6.12) id MAA03476; Fri, 30 Aug 1996 12:46:35 -0700 From: Archie Cobbs Message-Id: <199608301946.MAA03476@bubba.whistle.com> Subject: killproc program To: freebsd-hackers@freebsd.org Date: Fri, 30 Aug 1996 12:46:34 -0700 (PDT) X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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