summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sftp.c b/sftp.c
index 279f7d46e..da81897e4 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp.c,v 1.183 2018/04/10 00:10:49 djm Exp $ */ 1/* $OpenBSD: sftp.c,v 1.184 2018/04/13 05:04:12 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -253,6 +253,23 @@ cmd_interrupt(int signo)
253 errno = olderrno; 253 errno = olderrno;
254} 254}
255 255
256/*ARGSUSED*/
257static void
258sigchld_handler(int sig)
259{
260 int save_errno = errno;
261 pid_t pid;
262 const char msg[] = "\rConnection closed. \n";
263
264 /* Report if ssh transport process dies. */
265 while ((pid = waitpid(sshpid, NULL, WNOHANG)) == -1 && errno == EINTR)
266 continue;
267 if (pid == sshpid)
268 (void)write(STDERR_FILENO, msg, sizeof(msg) - 1);
269
270 errno = save_errno;
271}
272
256static void 273static void
257help(void) 274help(void)
258{ 275{
@@ -2227,6 +2244,7 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
2227 if (err != 0) 2244 if (err != 0)
2228 break; 2245 break;
2229 } 2246 }
2247 signal(SIGCHLD, SIG_DFL);
2230 free(remote_path); 2248 free(remote_path);
2231 free(startdir); 2249 free(startdir);
2232 free(conn); 2250 free(conn);
@@ -2296,6 +2314,7 @@ connect_to_server(char *path, char **args, int *in, int *out)
2296 signal(SIGTSTP, suspchild); 2314 signal(SIGTSTP, suspchild);
2297 signal(SIGTTIN, suspchild); 2315 signal(SIGTTIN, suspchild);
2298 signal(SIGTTOU, suspchild); 2316 signal(SIGTTOU, suspchild);
2317 signal(SIGCHLD, sigchld_handler);
2299 close(c_in); 2318 close(c_in);
2300 close(c_out); 2319 close(c_out);
2301} 2320}