summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
authormillert@openbsd.org <millert@openbsd.org>2016-10-18 12:41:22 +0000
committerDarren Tucker <dtucker@zip.com.au>2016-10-19 03:30:04 +1100
commit2c6697c443d2c9c908260eed73eb9143223e3ec9 (patch)
treeeb48a1c60a7c0ea2e364576838669c6573dabef7 /sftp.c
parentfd2a8f1033fa2316fff719fd5176968277560158 (diff)
upstream commit
Install a signal handler for tty-generated signals and wait for the ssh child to suspend before suspending sftp. This lets ssh restore the terminal mode as needed when it is suspended at the password prompt. OK dtucker@ Upstream-ID: a31c1f42aa3e2985dcc91e46e6a17bd22e372d69
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sftp.c b/sftp.c
index 1b5c9249..af6e3a69 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.176 2016/09/12 01:22:38 deraadt Exp $ */
+/* $OpenBSD: sftp.c,v 1.177 2016/10/18 12:41:22 millert Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -232,6 +232,18 @@ killchild(int signo)
/* ARGSUSED */
static void
+suspchild(int signo)
+{
+ if (sshpid > 1) {
+ kill(sshpid, signo);
+ while (waitpid(sshpid, NULL, WUNTRACED) == -1 && errno == EINTR)
+ continue;
+ }
+ kill(getpid(), SIGSTOP);
+}
+
+/* ARGSUSED */
+static void
cmd_interrupt(int signo)
{
const char msg[] = "\rInterrupt \n";
@@ -2213,6 +2225,9 @@ connect_to_server(char *path, char **args, int *in, int *out)
signal(SIGTERM, killchild);
signal(SIGINT, killchild);
signal(SIGHUP, killchild);
+ signal(SIGTSTP, suspchild);
+ signal(SIGTTIN, suspchild);
+ signal(SIGTTOU, suspchild);
close(c_in);
close(c_out);
}