diff options
Diffstat (limited to 'coreutils/timeout.c')
-rw-r--r-- | coreutils/timeout.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/coreutils/timeout.c b/coreutils/timeout.c index ff58a753a..802ddfc07 100644 --- a/coreutils/timeout.c +++ b/coreutils/timeout.c | |||
@@ -54,7 +54,9 @@ static HANDLE child = INVALID_HANDLE_VALUE; | |||
54 | static void kill_child(void) | 54 | static void kill_child(void) |
55 | { | 55 | { |
56 | if (child != INVALID_HANDLE_VALUE) { | 56 | if (child != INVALID_HANDLE_VALUE) { |
57 | kill_signal_by_handle(child, SIGTERM); | 57 | pid_t pid = (pid_t)GetProcessId(child); |
58 | if (pid) | ||
59 | kill(pid, SIGTERM); | ||
58 | } | 60 | } |
59 | } | 61 | } |
60 | 62 | ||
@@ -206,13 +208,15 @@ int timeout_main(int argc UNUSED_PARAM, char **argv) | |||
206 | status = signo == SIGKILL ? 137 : 124; | 208 | status = signo == SIGKILL ? 137 : 124; |
207 | 209 | ||
208 | pid = (pid_t)GetProcessId(child); | 210 | pid = (pid_t)GetProcessId(child); |
209 | kill(pid, signo); | 211 | if (pid) { |
212 | kill(pid, signo); | ||
210 | 213 | ||
211 | if (kill_timeout > 0) { | 214 | if (kill_timeout > 0) { |
212 | if (timeout_wait(kill_timeout, child, &status)) | 215 | if (timeout_wait(kill_timeout, child, &status)) |
213 | goto finish; | 216 | goto finish; |
214 | kill(pid, SIGKILL); | 217 | kill(pid, SIGKILL); |
215 | status = 137; | 218 | status = 137; |
219 | } | ||
216 | } | 220 | } |
217 | finish: | 221 | finish: |
218 | CloseHandle(child); | 222 | CloseHandle(child); |