9.3. Testing for running processes

For testing whether a particular process (with a known process ID) is currently running, a frequently found method is to send it a 0 signal and catch errors, similar to this example:

if kill -s 0 `cat $daemon_pid_file`; then
    ocf_log debug "Process is currently running"
    ocf_log warn "Process is dead, removing pid file"
    rm -f $daemon_pid_file

An approach far superior to this example is to instead test the functionality of the daemon by connecting to it with a client process, as shown in the example in Section 5.3, “monitor action”.