in reply to Getting PID's

Assuming you're on a *nix box, the straightforward way of getting the process ID of a child process is to do the fork()/exec() yourself.

Replies are listed 'Best First'.
Re: Re: Getting PIDs
by BazB (Priest) on Oct 15, 2002 at 23:59 UTC

    Update: Thanks to dws (++!), I stand corrected.

    I'm not convinced that you'll be able to get the PID of the command which is being exec()'d. Sure, fork() returns it's PID to the parent, but that's still only given you the PID of the perl process that is going to be doing the exec("command"), not the PID of command itself.

    I've had a quick look at IPC::Open3 - it returns the PID of the child process, but I'm not sure if it's the fork()'ed perl process, or the external command.
    Unfortunately I've not got time to look in that further right now - it is left as an exercise for the reader :-)

    Cheers,

    BazB

      I'm not convinced that you'll be able to get the PID of the command which is being exec()'d.

      exec() doesn't change the process id.