diff options
author | millert@openbsd.org <millert@openbsd.org> | 2016-10-18 12:41:22 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2016-10-19 03:30:04 +1100 |
commit | 2c6697c443d2c9c908260eed73eb9143223e3ec9 (patch) | |
tree | eb48a1c60a7c0ea2e364576838669c6573dabef7 /sftp.c | |
parent | fd2a8f1033fa2316fff719fd5176968277560158 (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.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp.c,v 1.176 2016/09/12 01:22:38 deraadt Exp $ */ | 1 | /* $OpenBSD: sftp.c,v 1.177 2016/10/18 12:41:22 millert 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 | * |
@@ -232,6 +232,18 @@ killchild(int signo) | |||
232 | 232 | ||
233 | /* ARGSUSED */ | 233 | /* ARGSUSED */ |
234 | static void | 234 | static void |
235 | suspchild(int signo) | ||
236 | { | ||
237 | if (sshpid > 1) { | ||
238 | kill(sshpid, signo); | ||
239 | while (waitpid(sshpid, NULL, WUNTRACED) == -1 && errno == EINTR) | ||
240 | continue; | ||
241 | } | ||
242 | kill(getpid(), SIGSTOP); | ||
243 | } | ||
244 | |||
245 | /* ARGSUSED */ | ||
246 | static void | ||
235 | cmd_interrupt(int signo) | 247 | cmd_interrupt(int signo) |
236 | { | 248 | { |
237 | const char msg[] = "\rInterrupt \n"; | 249 | const char msg[] = "\rInterrupt \n"; |
@@ -2213,6 +2225,9 @@ connect_to_server(char *path, char **args, int *in, int *out) | |||
2213 | signal(SIGTERM, killchild); | 2225 | signal(SIGTERM, killchild); |
2214 | signal(SIGINT, killchild); | 2226 | signal(SIGINT, killchild); |
2215 | signal(SIGHUP, killchild); | 2227 | signal(SIGHUP, killchild); |
2228 | signal(SIGTSTP, suspchild); | ||
2229 | signal(SIGTTIN, suspchild); | ||
2230 | signal(SIGTTOU, suspchild); | ||
2216 | close(c_in); | 2231 | close(c_in); |
2217 | close(c_out); | 2232 | close(c_out); |
2218 | } | 2233 | } |