in reply to Global variables over many children

Child processes get copies of the variables and environment. Changes in the child are local to the child. What you want is some form of shared memory. Check the IPC namespace and Mmap.

Update: Re your reply, indeed OTT for what you want. A pipe, perhaps with a signal handler to read and close it, will do for that.

After Compline,
Zaxo

  • Comment on Re: Global variables over many children

Replies are listed 'Best First'.
Re: Re: Global variables over many children
by Anonymous Monk on Dec 05, 2001 at 08:20 UTC
    Oh dear, It seems a bit OTT as im only trying to share a pid of a deeper forked child in a daemon.
    Anyway, I tried IPC::Sharable and got:
    IPC::Shareable::SharedMem: shmget: No such file or directory at /usr/lib/perl5/site_perl/5.6.0/IPC/Shareable.pm line 566 Could not create shared memory segment: at ./duke.pl line 8
    (Linux RH 7.2)
    Thanks for your help
      Don't use that. Use MLDBM::Sync, or just use a file if that seems like overkill.
        Using MLDBM::Sync worked perfectly, thanks. Up until the point I realised im gonna have to share an array :)
        So back to the shared memory question, whats going wrong there?