Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: delayed die and open3

by RazorbladeBidet (Friar)
on Mar 31, 2005 at 16:46 UTC ( [id://443882]=note: print w/replies, xml ) Need Help??


in reply to Re^2: delayed die and open3
in thread delayed die and open3

I was asking this same question myself.

Take out your "die" and it becomes evident what happens

The fork inside open3 (and yes, it does fork) forks the PROCESS. The whole thing. So your parent continues to run as normal, and, as the docs for IPC::open3 say, it does NOT wait for the child to run.

Therefore, the child keeps running after the parent is finished, dies and hits the die in your main program (because it forks the entire process).
--------------
"But what of all those sweet words you spoke in private?"
"Oh that's just what we call pillow talk, baby, that's all."

Replies are listed 'Best First'.
Re^4: delayed die and open3
by Random_Walk (Prior) on Mar 31, 2005 at 17:10 UTC

    Close I think but there must be more to it. If that is the case why does the child not run on through the rest of the code when the die is not in effect like fork would.

    # if forked why did the child not print done too ? nph>perl -MIPC::Open3 -le'print "dad: $$";eval{$pid=open3(*IN,*OUT,*ER +R,@ARGV)};print "kid: $pid";print "$$ $@" if($@);print <OUT>;print "d +one $$"' ec> dad: 42996 kid: 22394 Hi done 42996 # fork does ... nph>perl -MIPC::Open3 -le'print "dad: $$";eval{$pid=fork};print "kid: +$pid";print "$$ $@" if($@);print <OUT>;print "done $$"' echo Hi dad: 33442 kid: 27366 done 33442 nph>kid: 0 done 27366 nph>

    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!
      Because it's running exec as the child:
      ... exec @cmd # XXX: wrong process to croak from or croak "$Me: exec of @cmd failed"; ...
      which will abandon the process (unless it dies)
      --------------
      "But what of all those sweet words you spoke in private?"
      "Oh that's just what we call pillow talk, baby, that's all."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-03-29 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found