summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2010-07-01 13:07:00 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2010-07-01 13:07:00 +0000
commit76a5589160d25345dec1f060a51d5a6f6e3076e5 (patch)
tree3607843d31ce32e275ff4aab29367ab94870fb18
parent78390adbd52726d202f520bc7a4531e0fdac75dc (diff)
Fix a longstanding problem where if you suspend scp at the
password/passphrase prompt the terminal mode is not restored. OK djm@
-rw-r--r--usr.bin/ssh/scp.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c
index 7449ec46539..05fe6dd55ba 100644
--- a/usr.bin/ssh/scp.c
+++ b/usr.bin/ssh/scp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scp.c,v 1.165 2009/12/20 07:28:36 guenther Exp $ */
+/* $OpenBSD: scp.c,v 1.166 2010/07/01 13:06:59 millert Exp $ */
/*
* scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd).
@@ -140,6 +140,20 @@ killchild(int signo)
exit(1);
}
+static void
+suspchild(int signo)
+{
+ int status;
+
+ if (do_cmd_pid > 1) {
+ kill(do_cmd_pid, signo);
+ while (waitpid(do_cmd_pid, &status, WUNTRACED) == -1 &&
+ errno == EINTR)
+ ;
+ kill(getpid(), SIGSTOP);
+ }
+}
+
static int
do_local_cmd(arglist *a)
{
@@ -216,6 +230,10 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
close(reserved[0]);
close(reserved[1]);
+ signal(SIGTSTP, suspchild);
+ signal(SIGTTIN, suspchild);
+ signal(SIGTTOU, suspchild);
+
/* Fork a child to execute the command on the remote host using ssh. */
do_cmd_pid = fork();
if (do_cmd_pid == 0) {