Without --wait
, shell subprocesses can deadlock / are not reaped
#405
Labels
--wait
, shell subprocesses can deadlock / are not reaped
#405
For example:
The relevant code:
One thing to note, the subprocess will inherit watchmedo's file descriptors, which maybe isn't desirable. (Or maybe it is?) In this case it means
cat
will never exit since stdin is inherited fromwatchmedo
, which ifwatchmedo
was run from an interactive shell (for example) is a TTY that may never be closed. So an endless stream of cats which never exit will be spawned.But also,
wait(2)
is never called, so even if the subprocess does exit, it's never reaped. This accumulates zombie processes untilwatchmedo
exits, at which pointinit
will inherit those subprocesses and reap them. Of course that may never happen. You can see this withps -f
for example:One solution would be making
--wait
the default -- it's what I'd want personally for the use cases I have in mind.Alternately, something needs to wait around for the child processes to exit. That could be a thread which calls
wait
which will block, or something likeepoll_wait
can do it in a non-blocking way.The text was updated successfully, but these errors were encountered: