cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:
I just wrote a quick hack to check whether a daemon is running when it starts:
# quit if already running if (-e "/var/run/process_email.pid") { my $pid=9999999999; `cat /var/run/process_email.pid` =~ /(\d+)/ and $pid=$1; exit if (`ps aux|awk '{print \$2}' |grep $pid`); }
but I can't help thinking that there must be a more "perlish" way of doing this.
I did a quick search on CPAN, but I couldn't find a relevant module. Perhaps I was searching on the wrong term?
Anyone know if there's a standard way of doing this? Or is my hack similar to how others have approached this problem?
cLive ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: checking if daemon is running
by shiza (Hermit) on Dec 12, 2005 at 19:51 UTC | |
by cLive ;-) (Prior) on Dec 12, 2005 at 20:04 UTC | |
by shiza (Hermit) on Dec 12, 2005 at 20:14 UTC | |
|
Re: checking if daemon is running
by turo (Friar) on Dec 13, 2005 at 00:59 UTC |