Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Open pipe and fork or system command to retrieve PID and exit status - Best approach?

by aitap (Deacon)
on Aug 24, 2012 at 18:16 UTC ( #989603=note: print w/ replies, xml ) Need Help??


in reply to Open pipe and fork or system command to retrieve PID and exit status - Best approach?

launch process, retrieve PID, and Exit Status
At the same time? PID belongs to a running process; exit status is an int returned by terminating main(). Unless I've mistaken, you can't have both meaningful at the same time: when you have the exit status, the process is already terminated.
Anyway, have a look at IPC::Run. Other method is to pipe (thus you can read STDOUT), fork (thus you get the PID), exec then waitpid in the main procss (and then use $? to get the exit status).
Sorry if my advice was wrong.


Comment on Re: Open pipe and fork or system command to retrieve PID and exit status - Best approach?
Re^2: Open pipe and fork or system command to retrieve PID and exit status - Best approach?
by Anonymous Monk on Aug 24, 2012 at 20:47 UTC

    Sorry, wrong definition from me - I meant Return Status and PID.

    ie. -1 or 0 or 127 etc. and if 0, the PID as well.

    I am really trying to find most suitable approach to fork, and /most reliably/ work with PID obtained, over a period of time, and different script executions. So far I have decided to fork, exec, and in essence use

     do_something() if kill 0, $PID

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989603]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-07-10 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (202 votes), past polls