Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^4: Eval/Fork lesson of the day (no magic)

by tye (Sage)
on Sep 14, 2016 at 16:09 UTC ( #1171745=note: print w/replies, xml ) Need Help??

in reply to Re^3: Eval/Fork lesson of the day
in thread Eval/Fork lesson of the day

There is nothing magical going on here. You get the same problem if you just leave off the 'exit' from the code to be run by the child.

The only trap that 'eval' allows here is that, if the child 'die's, then the 'exit' can be skipped. If there is no 'eval', then that causes no problem because the child still exits without returning to the calling code that is meant to only be run by the parent. But with an 'eval', the 'die', in effect, transfers control up to the calling code and you end up with both parent and child running the calling code.

The only sharing is the standard sharing that happens when you fork. That is, the child gets a copy of (nearly) everything from the parent. Nothing is shared from the child to the parent (the exit status and resource usage is made available to the parent and output from the child can go to the same destination as the parent's output, of course).

Does that clear the mystery up for you?

- tye        

  • Comment on Re^4: Eval/Fork lesson of the day (no magic)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-09-30 21:47 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (126 votes). Check out past polls.