]> git.eshelyaron.com Git - emacs.git/commit
Fix deadlock when receiving SIGCHLD during 'pselect'.
authorPhilipp Stephani <phst@google.com>
Sun, 10 Jan 2021 15:31:12 +0000 (16:31 +0100)
committerPhilipp Stephani <phst@google.com>
Sat, 16 Jan 2021 18:46:44 +0000 (19:46 +0100)
commit8f0ce42d3eb9b212424a4a25a376287ffc94a73e
treeb05a83f36c0617184079a9fa5ce33a945e7e736e
parent66756df286bea6efd3f9a8290e38e8d77bdf0264
Fix deadlock when receiving SIGCHLD during 'pselect'.

If we receive and handle a SIGCHLD signal for a process while waiting
for that process, 'pselect' might never return.  Instead, we have to
explicitly 'pselect' that the process status has changed.  We do this
by writing to a pipe in the SIGCHLD handler and having
'wait_reading_process_output' select on it.

* src/process.c (child_signal_init): New helper function to create a
pipe for SIGCHLD notifications.
(child_signal_read, child_signal_notify): New helper functions to
read from/write to the child signal pipe.
(create_process): Initialize the child signal pipe on first use.
(handle_child_signal): Notify waiters that a process status has
changed.
(wait_reading_process_output): Make sure that we also catch
SIGCHLD/process status changes.

* test/src/process-tests.el
(process-tests/fd-setsize-no-crash/make-process): Remove workaround,
which is no longer needed.
src/process.c
test/src/process-tests.el