[openssh-commits] [openssh] 01/02: upstream: notify user immediately when underlying ssh process dies;
git+noreply at mindrot.org
git+noreply at mindrot.org
Sun Apr 15 07:53:21 AEST 2018
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit 3455f1e7c48e2e549192998d330214975b9b1dc7
Author: djm at openbsd.org <djm at openbsd.org>
Date: Fri Apr 13 05:04:12 2018 +0000
upstream: notify user immediately when underlying ssh process dies;
patch from Thomas Kuthan in bz2719; ok dtucker@
OpenBSD-Commit-ID: 78fac88c2f08054d1fc5162c43c24162b131cf78
---
sftp.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/sftp.c b/sftp.c
index 279f7d46..da81897e 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.183 2018/04/10 00:10:49 djm Exp $ */
+/* $OpenBSD: sftp.c,v 1.184 2018/04/13 05:04:12 djm Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm at openbsd.org>
*
@@ -253,6 +253,23 @@ cmd_interrupt(int signo)
errno = olderrno;
}
+/*ARGSUSED*/
+static void
+sigchld_handler(int sig)
+{
+ int save_errno = errno;
+ pid_t pid;
+ const char msg[] = "\rConnection closed. \n";
+
+ /* Report if ssh transport process dies. */
+ while ((pid = waitpid(sshpid, NULL, WNOHANG)) == -1 && errno == EINTR)
+ continue;
+ if (pid == sshpid)
+ (void)write(STDERR_FILENO, msg, sizeof(msg) - 1);
+
+ errno = save_errno;
+}
+
static void
help(void)
{
@@ -2227,6 +2244,7 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
if (err != 0)
break;
}
+ signal(SIGCHLD, SIG_DFL);
free(remote_path);
free(startdir);
free(conn);
@@ -2296,6 +2314,7 @@ connect_to_server(char *path, char **args, int *in, int *out)
signal(SIGTSTP, suspchild);
signal(SIGTTIN, suspchild);
signal(SIGTTOU, suspchild);
+ signal(SIGCHLD, sigchld_handler);
close(c_in);
close(c_out);
}
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list