From: "Ara.T.Howard" Date: 2005-06-25T11:00:32+09:00 Subject: Re: launching process and keeping track of pid On Sat, 25 Jun 2005, Joe Van Dyk wrote: > Hi, > > How can I launch a program from Ruby and monitor it to see if it's > running? On a unix platform. > > I assume I'd probably need to launch the program, capture the pid of > the started process somehow, and start a thread that monitors the > /proc directory to see if the pid is in there? > > Thanks, > Joe this might be helpful: # # returns true if pid is running, false otherwise # def alive pid #--{{{ pid = Integer("#{ pid }") begin Process::kill 0, pid true rescue Errno::ESRCH false end #--}}} end alias alive? alive cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================