diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/sftp.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c index 042780cb7d2..8f1a5ed9e73 100644 --- a/usr.bin/ssh/sftp.c +++ b/usr.bin/ssh/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@openbsd.org> * @@ -231,6 +231,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) { @@ -2192,6 +2209,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); @@ -2248,6 +2266,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); } |