From: Sam Roberts Date: 2005-03-31T22:55:06+09:00 Subject: Re: Getting process id of started process Wrote Joe Van Dyk , on Thu, Mar 31, 2005 at 07:58:11AM +0900: > 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? You can't, not like this anyhow. You aren't running cat directly, you are calling the shell, /bin/sh, which is processing the redirect command (>/dev/null). Only the shell knows the pid of cat. You actually have ruby --fork()--> ruby --system()--> /bin/sh --fork()/exec()--> /bin/cat So there are 3 processes inherited from your main ruby executable. Kernel.fork/exec/system are fairly thin wrappers around the C equivalents, so a unix prog manual should cover whats happening, as well as ways of doing whatever you are trying to do. Sam -- Sam Roberts