From 2f69dba5df8caaf9eda658c1808b1379e9949f22 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sun, 5 Feb 2017 13:23:22 +0100 Subject: timeout: fix race possibly terminating wrong process The race is unlikely, as timeout(1) needs to receive a signal in the few operations between waitpid() returning and exit(). Also the system needs to have reallocated the just released pid in this time window. Previously we never disabled the signal handler that sent the termination signal to the "child" pid. However once waitpid() has reaped the child, the system is free to allocate that pid, so we must ensure we don't process any further signals. * build-aux/gen-lists-of-programs.sh: Build timeout(1) optionally... * configure.ac: ...predicated on sigsuspend() being available. * src/timeout.c (block_cleanup): A new function to ensure the cleanup() handler is disabled after waitpid has returned. (main): Use sigsuspend() to wait with cleanup() enabled but disabled once it returns, and thus disabled for the waitpid() call. (monitored_pid): Change to the more accurate pid_t. * NEWS: Mention the fix. Fixes http://bugs.gnu.org/25624 --- build-aux/gen-lists-of-programs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build-aux') diff --git a/build-aux/gen-lists-of-programs.sh b/build-aux/gen-lists-of-programs.sh index 2666492e8..cdbcd0a9e 100755 --- a/build-aux/gen-lists-of-programs.sh +++ b/build-aux/gen-lists-of-programs.sh @@ -32,6 +32,7 @@ build_if_possible_progs=' pinky stdbuf stty + timeout uptime users who @@ -120,7 +121,6 @@ normal_progs=' tail tee test - timeout touch tr true -- cgit v1.2.3-70-g09d2