Previously, eio_posix installed a signal handler that would reap all child processs. However, this may cause problems if some other library is used to spawn a process (e.g. Stdlib.Unix or Lwt).
EIO_BACKEND=posix dune exec -- ./stress/stress_proc.exe
+Finished process stress test: ran 10000 processes in 2.70s # Old code
+Finished process stress test: ran 10000 processes in 2.89s # New code
Eio_linux is unaffected, as it uses process descriptors instead of signals.
Previously, eio_posix installed a signal handler that would reap all child processs. However, this may cause problems if some other library is used to spawn a process (e.g.
Stdlib.Unix
orLwt
).Now, it polls every known child process individually when signalled, so only processes spawned by Eio will be reaped. This is what Lwt does too (https://github.com/ocsigen/lwt/blob/cc05e2bda6c34126a3fd8d150ee7cddb3b8a440b/src/unix/lwt_unix.cppo.ml#L2364).
This is slightly slower than the old code:
Eio_linux is unaffected, as it uses process descriptors instead of signals.
This is needed for https://github.com/ocsigen/lwt/issues/991.