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))
?