=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/sftp.c,v retrieving revision 1.184 retrieving revision 1.185 diff -u -r1.184 -r1.185 --- src/usr.bin/ssh/sftp.c 2018/04/13 05:04:12 1.184 +++ src/usr.bin/ssh/sftp.c 2018/04/26 14:47:03 1.185 @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.c,v 1.184 2018/04/13 05:04:12 djm Exp $ */ +/* $OpenBSD: sftp.c,v 1.185 2018/04/26 14:47:03 bluhm Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -61,7 +61,7 @@ int batchmode = 0; /* PID of ssh transport process */ -static pid_t sshpid = -1; +static volatile pid_t sshpid = -1; /* Suppress diagnositic messages */ int quiet = 0; @@ -242,8 +242,10 @@ /* Report if ssh transport process dies. */ while ((pid = waitpid(sshpid, NULL, WNOHANG)) == -1 && errno == EINTR) continue; - if (pid == sshpid) + if (pid == sshpid) { (void)write(STDERR_FILENO, msg, sizeof(msg) - 1); + sshpid = -1; + } errno = save_errno; } @@ -2500,7 +2502,7 @@ if (batchmode) fclose(infile); - while (waitpid(sshpid, NULL, 0) == -1) + while (waitpid(sshpid, NULL, 0) == -1 && sshpid > 1) if (errno != EINTR) fatal("Couldn't wait for ssh process: %s", strerror(errno));