From 9a42961e584e5ae5c222d5bd043ab39c0df444f0 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Thu, 26 Apr 2018 14:47:04 +0000 Subject: Since the previous commit, ssh regress test sftp-chroot was failing. The sftp program terminated with the wrong exit code as sftp called fatal() instad of exit(0). So when the sigchld handler waits for the child, remember that it was found. Then don't expect that main() can wait again. OK dtucker@ --- usr.bin/ssh/sftp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'usr.bin/ssh/sftp.c') diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c index 8f1a5ed9e73..e83177f681b 100644 --- a/usr.bin/ssh/sftp.c +++ b/usr.bin/ssh/sftp.c @@ -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 @@ FILE* infile; 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 @@ sigchld_handler(int sig) /* 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 @@ main(int argc, char **argv) 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)); -- cgit v1.2.3