signals and ssh

Markus Friedl markus at openbsd.org
Mon Nov 18 22:35:30 EST 2002


hi, please test this.  if ssh is called with SIGINT ignored (e.g.
from a backup system, with rmt) then ssh should not overwrite set
it's own handler.

Index: clientloop.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/clientloop.c,v
retrieving revision 1.104
diff -u -r1.104 clientloop.c
--- clientloop.c	22 Aug 2002 19:38:42 -0000	1.104
+++ clientloop.c	18 Nov 2002 11:33:45 -0000
@@ -888,10 +888,16 @@
 
 	client_init_dispatch();
 
-	/* Set signal handlers to restore non-blocking mode.  */
-	signal(SIGINT, signal_handler);
-	signal(SIGQUIT, signal_handler);
-	signal(SIGTERM, signal_handler);
+	/*
+	 * Set signal handlers, (e.g. to restore non-blocking mode)
+	 * but don't overwrite SIG_IGN, matches behaviour from rsh(1)
+	 */
+	if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+		signal(SIGINT, signal_handler);
+	if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
+		signal(SIGQUIT, signal_handler);
+	if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
+		signal(SIGTERM, signal_handler);
 	if (have_pty)
 		signal(SIGWINCH, window_change_handler);
 



More information about the openssh-unix-dev mailing list