From: Saynatkari Date: 2005-03-31T09:20:27+09:00 Subject: Re: Getting process id of started process In data 3/31/2005, "Joe Van Dyk" ha scritto: >I've attatched code and test code at >http://rafb.net/paste/results/2Rj4rb87.html , if someone wants to take >a look. Hopefully it's clear about what I want to do. > > >On Wed, 30 Mar 2005 14:57:51 -0800, Joe Van Dyk wrote: >> Say I want to start a long running shell process (and monitor that process). >> >> def start_process >> @process_id = fork do >> Kernel.system "cat /dev/zero > /dev/null" >> end >> end >> >> However, @process_id doesn't contain the pid of the cat process. How >> can I capture the pid of that process? Kernel#fork returns twice, once in the child (return value of nil), once in the parent (returns the pid). Try a if/else block and see if it works? Re: $?, I think that is the only way to get the Process::Status object. I do not think Process#wait(pid) returns immediately though I may be wrong. >> Thanks, >> Joe E