brian42miller has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,

How can you execute a program and get the pid without using a pipe? I would like to start a process and just monitor the pid to see when it finishes? The system command does not return the pid and the open command seems to only return the pid if there is a pipe.

Thanks

Brian Miller

Replies are listed 'Best First'.
Re: spawn process
by zentara (Cardinal) on Jul 09, 2011 at 00:56 UTC
Re: spawn process
by BrowserUk (Patriarch) on Jul 08, 2011 at 19:59 UTC

    Why do you need the pid if all you are going to do is wait until it finishes?

    system 'yourcommand'; ##now it is finished.

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I need to spawn multiple processes and have them running in the background while the main program is doing other things and just monitoring for completion of the other processes. Brian

        If you are on Windows then you can do:

        my $pid = system 1, 'yourCommand';

        On other platforms you'll need to fiddle around with fork & exec.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.