In article <200101101750.f0AHoZ217570 / orsay1.moulon.inra.fr>,
ts  <decoux / moulon.inra.fr> wrote:
>>>>>> "L" == Laurence J Lane <ljlane / debian.org> writes:
>
>L> How can I get the PID of a program run in a ruby script. I've 
>L> looked at open, popen, system, and %x//, and various Process 
>L> methods, but haven't figured it out.
>
> #fork and #exec, no ?
>

Unfortuneatly, no.  I've been trying to do the same thing.  The pid you
get back from fork is the pid of the shell that the external command was
exec'ed into, not the pid for the command itself.  What I find is that if
I send a SIGTERM to the pid I get back from fork it does indeed kill the
shell, but the child pid (the pid for the command that was exec'ed) isn't
effected and the child just continues to run.

If you weren't running an external program, but instead were running some
ruby code in the fork, then killing the pid you get back will work. But in
the case of running an external command you can kill the pid returned from
fork, but the external program doesn't seeem to be effected.

Phil