Subject: Re: Should programs clean-up their /var/run/*.pid files?
To: Paul Goyette <paul@whooppee.com>
From: Andrew Brown <codewarrior@daemon.org>
List: current-users
Date: 06/06/1997 12:04:21
>Right now, I'm using:
>
>	if [ `ps -ax | grep -c " xntpd " -gt 1 ]; ...
>
>to detect if xntpd is still running, but that isn't a very reliable way to
>do it (ie, what if some user passed " xntpd " as an argument to their own
>program?).  Anyone got any better ideas?  Or should xntpd be fixed to
>remove its .pid file?

        if ( kill -0 `cat /var/run/xntpd.pid` 2>/dev/null ); ...

will tell you if something is running with that pid which will
probably be xntpd (unless xntp has died and that particular pid has
been recycled and you happen to catch it).

much cleaner...

-- 
|-----< "CODE WARRIOR" >-----|
andrew@echonyc.com (TheMan)        * "ah!  i see you have the internet
codewarrior@daemon.org                               that goes *ping*!"
warfare@graffiti.com      * "information is power -- share the wealth."