diff options
author | Paul Smith <psmith@gnu.org> | 2014-02-01 23:08:59 -0500 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2014-02-01 23:12:04 -0500 |
commit | 88713683fed38fa5a7a649d065c73f4d945bade7 (patch) | |
tree | fe3967ac73c826d10ecba8166a10901f80d63e06 | |
parent | a7cac0f0e3c9e5e84aa6d77b05e8aa5a7b1ade68 (diff) | |
download | gunmake-88713683fed38fa5a7a649d065c73f4d945bade7.tar.gz |
* job.c (set_child_handler_action_flags): [SV 41341]
Ensure signal handler is in place before alarm(1).
-rw-r--r-- | job.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1116,10 +1116,20 @@ set_child_handler_action_flags (int set_handler, int set_alarm) /* If we're about to enter the read(), set an alarm to wake up in a second so we can check if the load has dropped and we can start more work. On the way out, turn off the alarm and set SIG_DFL. */ - alarm (set_handler ? 1 : 0); - sa.sa_handler = set_handler ? job_noop : SIG_DFL; - sa.sa_flags = 0; - sigaction (SIGALRM, &sa, NULL); + if (set_handler) + { + sa.sa_handler = job_noop; + sa.sa_flags = 0; + sigaction (SIGALRM, &sa, NULL); + alarm (1); + } + else + { + alarm (0); + sa.sa_handler = SIG_DFL; + sa.sa_flags = 0; + sigaction (SIGALRM, &sa, NULL); + } } #endif } |