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

Re: Global Variables Not Updated in Child Process

by philipbailey (Chaplain)
on Nov 16, 2012 at 08:20 UTC ( #1004147=note: print w/ replies, xml ) Need Help??


in reply to Global Variables Not Updated in Child Process

When you fork a process, then parent and child are initially more or less exact copies, including the values of variables, except for the return code of fork(). But the key word there is copies. Those two processes are now independent and variables, "global" or not, are not connected in any way.

That's fortunate, as for Unix-like operating systems, and probably others, all processes are ultimately children (or children of children etc.) of one startup process. If data were always shared between parent and child, all processes would have some common state.

As to how you can solve your problem, the best approach depends on the details of what you are doing. You could share data, for example, through disc files, or by various IPC mechanisms, e.g. sockets, pipes. See perlipc.


Comment on Re: Global Variables Not Updated in Child Process

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-08-30 02:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls