[OT] pidof considered harmful (was Re: [BusyBox] pidof problem)

Charlie Brady charlieb-busybox at e-smith.com
Tue Apr 20 15:06:16 UTC 2004


On Tue, 20 Apr 2004, Gabor Z. Papp wrote:

> I wrote a script to start/stop the nfs services, where the stop part
> look something like this:
> 
> exportfs -au
> kill -9 `pidof mountd 2>/dev/null` 2>/dev/null
> kill -9 `pidof nfsd 2>/dev/null` 2>/dev/null
> kill -9 `pidof statd 2>/dev/null` 2>/dev/null
> kill -9 `pidof lockd 2>/dev/null` 2>/dev/null
> modprobe -r nfsd
> 
> I was using 2>/dev/null to supress the non existing process error
> messages. The stop process breaked abnormally with an error message
> "Killed" and the statd process was not killed.

FWIW, you might look at "daemontools" or "runit" for managing services. 
Significantly more reliable than trying to guess. And you should only use 
-9 as a last resort.

--
Charlie

A: Because we read from top to bottom, left to right.
Q: Why should i start my reply below the quoted text?




More information about the busybox mailing list