diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2018-04-13 05:04:13 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2018-04-13 05:04:13 +0000 |
commit | a5fb210d99f69bb7edec15e9adacbe9f14efaaf6 (patch) | |
tree | 47cae97aa5eeee47a2298093735aca85d10b9de7 /usr.bin | |
parent | 8adbf9e98a5b65138571bedc1198e1eca804ed21 (diff) |
notify user immediately when underlying ssh process dies;
patch from Thomas Kuthan in bz2719; ok dtucker@
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); } |