diff options
Diffstat (limited to 'sftp.c')
-rw-r--r-- | sftp.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp.c,v 1.184 2018/04/13 05:04:12 djm Exp $ */ | 1 | /* $OpenBSD: sftp.c,v 1.185 2018/04/26 14:47:03 bluhm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
4 | * | 4 | * |
@@ -81,7 +81,7 @@ FILE* infile; | |||
81 | int batchmode = 0; | 81 | int batchmode = 0; |
82 | 82 | ||
83 | /* PID of ssh transport process */ | 83 | /* PID of ssh transport process */ |
84 | static pid_t sshpid = -1; | 84 | static volatile pid_t sshpid = -1; |
85 | 85 | ||
86 | /* Suppress diagnositic messages */ | 86 | /* Suppress diagnositic messages */ |
87 | int quiet = 0; | 87 | int quiet = 0; |
@@ -264,8 +264,10 @@ sigchld_handler(int sig) | |||
264 | /* Report if ssh transport process dies. */ | 264 | /* Report if ssh transport process dies. */ |
265 | while ((pid = waitpid(sshpid, NULL, WNOHANG)) == -1 && errno == EINTR) | 265 | while ((pid = waitpid(sshpid, NULL, WNOHANG)) == -1 && errno == EINTR) |
266 | continue; | 266 | continue; |
267 | if (pid == sshpid) | 267 | if (pid == sshpid) { |
268 | (void)write(STDERR_FILENO, msg, sizeof(msg) - 1); | 268 | (void)write(STDERR_FILENO, msg, sizeof(msg) - 1); |
269 | sshpid = -1; | ||
270 | } | ||
269 | 271 | ||
270 | errno = save_errno; | 272 | errno = save_errno; |
271 | } | 273 | } |
@@ -2554,7 +2556,7 @@ main(int argc, char **argv) | |||
2554 | if (batchmode) | 2556 | if (batchmode) |
2555 | fclose(infile); | 2557 | fclose(infile); |
2556 | 2558 | ||
2557 | while (waitpid(sshpid, NULL, 0) == -1) | 2559 | while (waitpid(sshpid, NULL, 0) == -1 && sshpid > 1) |
2558 | if (errno != EINTR) | 2560 | if (errno != EINTR) |
2559 | fatal("Couldn't wait for ssh process: %s", | 2561 | fatal("Couldn't wait for ssh process: %s", |
2560 | strerror(errno)); | 2562 | strerror(errno)); |