Add cleanup_signal argument to run() and process$new(). This instructs processx to use softer termination on GC so that the callr cleanup handler may run.
Add signal arguments to kill() and kill_tree() methods. Used internally to support the above, and externally by event loops.
Since the kill signal may now be ignored by the process, poll for SIGCHLD with a timeout. This is implemented using process_wait() and tested with a new dynlib sigtermignore that installs a SIGTERM handler that ignores the signal.
I'm not 100% happy with the API implemented here. I can call kill_tree(signal = SIGTERM) in an event loop and register a subsequent SIGKILL with a delay, this part is fine. However, when processes created with cleanup_signal = SIGTERM fail to properly quit on GC, the processes might not be killed. Also it seems that close_connections = TRUE also causes the process to finish (e.g. it causes processes linked to sigtermignore to terminate), and I'm not sure how this interacts with SIGTERM cleanup.
Would it make sense to revive the grace argument and do staged termination with SIGTERM and SIGKILL by default?
Branched from #357
Add
cleanup_signal
argument torun()
andprocess$new()
. This instructs processx to use softer termination on GC so that the callr cleanup handler may run.Add
signal
arguments tokill()
andkill_tree()
methods. Used internally to support the above, and externally by event loops.Since the kill signal may now be ignored by the process, poll for
SIGCHLD
with a timeout. This is implemented usingprocess_wait()
and tested with a new dynlibsigtermignore
that installs aSIGTERM
handler that ignores the signal.I'm not 100% happy with the API implemented here. I can call
kill_tree(signal = SIGTERM)
in an event loop and register a subsequentSIGKILL
with a delay, this part is fine. However, when processes created withcleanup_signal = SIGTERM
fail to properly quit on GC, the processes might not be killed. Also it seems thatclose_connections = TRUE
also causes the process to finish (e.g. it causes processes linked to sigtermignore to terminate), and I'm not sure how this interacts with SIGTERM cleanup.Would it make sense to revive the
grace
argument and do staged termination with SIGTERM and SIGKILL by default?