Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Global Variables Not Updated in Child Process

by philipbailey (Curate)
on Nov 16, 2012 at 08:20 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1004147]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-24 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found