in reply to The Singleton design pattern and fork();

I'm afraid that's right. A fork makes a complete, independent copy of the memory state of the parent. Your singleton has become a doubleton and there is no connection between the copies. You'll have to share memory, use threads, or do interprocess communication (such as sockets).
  • Comment on Re: The Singleton design pattern and fork();

Replies are listed 'Best First'.
Re: The Singleton design pattern and fork();
by skx (Parson) on Feb 22, 2003 at 05:47 UTC

     Thanks for the reply, and for confirming my suspicion.

     I was assuming that because the $oneTrueSelf' reference would be present in both the parent and the child changes would be reflected in both.

     (Hmm I guess this doesn't really qualify as a Perl question at all, just a misundertanding of how processes work)

    Steve
    ---
    steve.org.uk