PHP Classes
elePHPant
Icontem

Zombie children

Recommend this page to a friend!

      PHP Async Task  >  All threads  >  Zombie children  >  (Un) Subscribe thread alerts  
Subject:Zombie children
Summary:Just a few bugfixes
Messages:2
Author:Mikkel Christensen
Date:2015-06-10 19:36:00
 

 


  1. Zombie children   Reply   Report abuse  
Mikkel Christensen - 2015-06-10 19:36:00
Hey,

I haven't decided if I'll be using this or rolling my own yet... This seems pretty minimal, yet easy to extend - nice work.

I did a bit of testing yesterday, and quickly ended out with loads of dead php processes though.

The children do not finish until the parent is done - which in my case would be catastrophic... I'm writing an async daemon that will probably run for weeks or months at a time and running thousands of async tasks during its lifespan... so zombie processes left behind by each task would very quickly acumulate and kill the server.

Anyway, it was pretty easy to fix - just add this as first line of the execute function:

pcntl_signal(SIGCHLD, SIG_IGN);

Children then exit as soon as they are done, without any negative effects as far as I can tell.

Another issue I noticed is line 221, which says:

is_null(shm_get_var(self::$shmId, 112105100)) !== null

is_null returns either true or false (so the above will always be true)... I'm guessing it should be:

shm_get_var(self::$shmId, 112105100) !== null

or

!is_null(shm_get_var(self::$shmId, 112105100))

?

  2. Re: Zombie children   Reply   Report abuse  
Dmitry Mamontov - 2015-06-11 07:32:07 - In reply to message 1 from Mikkel Christensen
Hello! By your advice and fix it added. In the latter case was a simple typo. Thank you for the correction.