From: David Masover Date: 2009-02-17T08:47:22+09:00 Subject: Re: Controlling a forked process Michael Satterwhite wrote: > What is causing the first call to fork to be tied to the first process > and the second call to fork to be tied to the second process? Because the first call to fork is both spawning and returning the process id that was spawned. > Is it > simply that it's returning the pid of the most recently spawned process? > Close. It is returning the pid of the process that this particular call to fork spawned. This is effectively the same, but you're overthinking it. Let me make it as simple as I possibly can: this_pid = fork { this child body } No matter where you do that in your code, or how often you do it, that code will always do what you expect. The variable on the left will always receive the pid corresponding to the process which is now running the code on the right.