rktio: fix signal mask for subprocesses

... by making `centralized_unblock_child_signal` actually unblock SIGCHLD.

Closes #2176
This commit is contained in:
Matthew Flatt 2018-07-20 06:43:50 -06:00
parent e2435d7187
commit b40fdb7dd7
3 changed files with 37 additions and 0 deletions

View File

@ -543,6 +543,22 @@
(close-input-port (car p))
(close-input-port (cadddr p))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check the process state for subprocesses to ensure that, for example,
;; SIGCHLD is not blocked
(unless (eq? (system-type) 'windows)
(let* ([dir (make-temporary-file "sub~a" 'directory)]
[exe (build-path dir "check")])
(when (system* (or (find-executable-path "cc")
(find-executable-path "gcc"))
"-o"
exe
(path->complete-path "unix_check.c" (or (current-load-relative-directory)
(current-directory))))
(test #t 'subprocess-state (system* exe)))
(delete-directory/files dir)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(for ([f (list tmpfile tmpfile2)] #:when (file-exists? f)) (delete-file f))

View File

@ -0,0 +1,17 @@
#include <stdio.h>
#include <signal.h>
/* Make sure a child process is started with normal properties, such
as no blocked signals */
int main()
{
sigset_t set, old_set;
sigemptyset(&set);
sigprocmask(SIG_BLOCK, &set, &old_set);
return (sigismember(&old_set, SIGCHLD)
|| sigismember(&old_set, SIGINT)
|| sigismember(&old_set, SIGHUP)
|| sigismember(&old_set, SIGQUIT));
}

View File

@ -392,6 +392,10 @@ void centralized_block_child_signal()
void centralized_unblock_child_signal()
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGCHLD);
sigprocmask(SIG_UNBLOCK, &set, NULL);
}
void centralized_start_child_signal_handler()