openSUSE / Mojo-IOLoop-ReadWriteProcess

Execute external programs or internal code blocks as separate process
Other
10 stars 13 forks source link

Fix race of SIG{CHLD} handler setup #17

Closed cfconrad closed 2 years ago

cfconrad commented 2 years ago

The SIG{CHLD} must be setup before we fork(). Otherwise there is a small risk of a race, that the fork already exited before the SIG{CHLD} was set and we end up in a $p->is_running() endless loop.

It is easy to reproduce, just place a sleep 1 before this enable() call here https://github.com/mudler/Mojo-IOLoop-ReadWriteProcess/blob/master/lib/Mojo/IOLoop/ReadWriteProcess.pm#L340