[UPHPU] unable to define constant after forking process

Jason Feriante jason.feriante at gmail.com
Sat Sep 29 14:37:18 MDT 2012


abstractly creating something non-abstract / concrete seems inherently
problematic;
I wonder why you need a namespace? Is there a reason you can't just spin up
a new object with each fork that will execute your child behavior?

I'm thinking some combination of factory & flyweight pattern

I'm not sure what you intend with your namespacing, but a new object should
give you something globally unique.
e.g. instantiating a new child object once you're in the child process...

Maybe some variation of this could work.

$pid = pcntl_fork();
if ($pid == -1) {
     die('could not fork');
} else if ($pid) {
     // we are the parent
     pcntl_wait($status); //Protect against Zombie children
} else {
     // we are the child
     $child = new Child($config);
     $child->do_something();
}


-Jason

On Sat, Sep 29, 2012 at 1:48 PM, Wade Shearer <wadeshearer.lists at me.com>wrote:

> I have a foreach in which I use pcntl_fork to fork off an independent
> process. This is so that thinks can be executed non-linearly. I want to
> define a constant immediately after the fork. My script fails however
> stating it cannot define the constant because it is already defined (the
> second loop in the foreach I assume). Is there a way for the fork to
> maintain a unique global namespace?
>
> _______________________________________________
>
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
>


More information about the UPHPU mailing list