=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/scp.c,v retrieving revision 1.165 retrieving revision 1.166 diff -u -r1.165 -r1.166 --- src/usr.bin/ssh/scp.c 2009/12/20 07:28:36 1.165 +++ src/usr.bin/ssh/scp.c 2010/07/01 13:06:59 1.166 @@ -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 @@ 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) { @@ -215,6 +229,10 @@ /* Free the reserved descriptors. */ 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();