On Fri, Aug 02, 2002 at 03:41:35AM +0900, Harry Ohlsen wrote: > To check whether a process with a given ID is still running on unix, I would > normally use the following C code ... > > if (kill(pid, 0) == 0) > printf("alive"); > else > printf("dead"); > > However, the return code from Process.kill() doesn't seem to match the system > call. Having a cursory look at the source in process.c (version 1.6.7), it > looks like the value returned is the number of kill() calls that were > successfully made. When kill() doesn't actually kill a process, it seems to raise an Errno::ESRCH exception (on both Ruby-1.6.7 and Ruby-1.7.2). I've been doing this to determine if a process is running: def is_running(pid) return Process.getpgid(pid) != -1 end but this doesn't work on Ruby 1.7, since it raises an Errno::ESRCH instead of returning -1. So I have had to modify it to do this: def is_running(pid) begin return Process.getpgid(pid) != -1 rescue Errno::ESRCH return false end end Paul