From 1f3c2cb7e18c94523d4db44ca4650045ce22b780 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 4 Jun 2003 12:40:40 +0000 Subject: kill ssh process upon receipt of signal, bz #241. based on patch from esb AT hawaii.edu; ok markus@ --- usr.bin/ssh/scp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'usr.bin/ssh') 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; } -- cgit v1.2.3