OSSubprocess icon indicating copy to clipboard operation
OSSubprocess copied to clipboard

OSSubprocess reaps processes that it did not spawn

Open janvrany opened this issue 2 years ago • 0 comments

OSSubprocess' process reaping logic reaps all child processes, not only those that it has spawned (that is, processes spawned by means of OSSubprocess). Therefore is may happen (does happen) that it does reap processes spawned by some other means (for example, manual calls to posix_spawn()) making OSSubprocess essentially incompatible (unusable) with any code that spawns processes.

I'd argue the code should be changed to only reap processes it has spawned - that's not a big deal as it keeps track of spawned processes anyways. So instead of waitpid(-1,...) call waitpid() for each process (it has spawned).

While at it, it is not necessary to have reaper process running when there are no outstanding live child processes.

janvrany avatar Aug 21 '23 12:08 janvrany