I would go further than checking the content of /var/run/syslogd.pid and seeing whether there's a process running with that id. After all, if syslogd went down, another process could have taken PID syslogd was using.
Furthermore, to check whether a PID is in use, and what program is using it, I would use neither kill, nor ps. I'd run something like (untested):
my $pidfile = "/var/run/syslogd.pid";
if (-e $pidfile &&
qx "cat /proc/`cat $pidfile`/cmdline" =~ /^syslogd$/) {
... syslog is running ...
}
Notes:
- On my systems, you must be root to be able to read /var/run/syslogd.pid. Your milage may vary.
- It's not foolproof. Something may have removed the PID file for instance.
- This is for a 2.4 Linux kernel. Different OSses (or Linux versions) may have a different /proc file system layout, or no /proc filesystem at all. The information from the file cmdline may be elsewhere, or not available at all.