diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2003-06-04 12:40:40 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2003-06-04 12:40:40 +0000 |
commit | 1f3c2cb7e18c94523d4db44ca4650045ce22b780 (patch) | |
tree | dfee421f5ea5625217cc476f3b2fd8464b8cc1d8 /usr.bin | |
parent | 2233921a7aa6fce35fd807ba7c424d7d73fb21fc (diff) |
kill ssh process upon receipt of signal, bz #241.
based on patch from esb AT hawaii.edu; ok markus@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/scp.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c index 2c76c013849..b1d9b4c9c0e 100644 --- a/usr.bin/ssh/scp.c +++ b/usr.bin/ssh/scp.c @@ -71,7 +71,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: scp.c,v 1.104 2003/06/04 12:18:49 djm Exp $"); +RCSID("$OpenBSD: scp.c,v 1.105 2003/06/04 12:40:39 djm Exp $"); #include "xmalloc.h" #include "atomicio.h" @@ -103,7 +103,16 @@ int showprogress = 1; char *ssh_program = _PATH_SSH_PROGRAM; /* This is used to store the pid of ssh_program */ -pid_t do_cmd_pid; +pid_t do_cmd_pid = -1; + +static void +killchild(int signo) +{ + if (do_cmd_pid > 1) + kill(do_cmd_pid, signo); + + _exit(1); +} /* * This function executes the given command as the specified user on the @@ -166,6 +175,9 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc) *fdout = pin[1]; close(pout[1]); *fdin = pout[0]; + signal(SIGTERM, killchild); + signal(SIGINT, killchild); + signal(SIGHUP, killchild); return 0; } |