Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Feb 1998 15:12:57 +0100
From:      Martin Cracauer <cracauer@cons.org>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        freebsd-current@FreeBSD.ORG, cracauer@cons.org
Subject:   Re: cvs commit: src/bin/sh jobs.c
Message-ID:  <19980210151257.23319@cons.org>
In-Reply-To: <19980207195952.24691@cons.org>; from Martin Cracauer on Sat, Feb 07, 1998 at 07:59:52PM %2B0100
References:  <199802071645.DAA14279@godzilla.zeta.org.au> <19980207195952.24691@cons.org>

next in thread | previous in thread | raw e-mail | index | archive | help
The patch below makes sh pass all my tests. In addition to the last
one, it also behaves right on:

#!./testshell

echo 'Test 2: You should not be able to exit cat with SIGINT.'
echo '        But SIGQUIT should abort cat with coredump while'
echo '        the shell should continue and call cat again.'
echo '        SIGTERM should exit the whole script.'

set -x
trap '' 2
while : ; do cat ; echo -n $? ; done
# End of script





*** sh/jobs.c	Tue Feb 10 10:42:47 1998
--- sh.cra/jobs.c	Tue Feb 10 14:54:50 1998
***************
*** 86,89 ****
--- 86,92 ----
  int curjob;			/* current job */
  #endif
+ sig_t oldsigint;
+ sig_t oldsigquit;
+ int oldsigs_valid = 0;
  
  #if JOBS
***************
*** 575,580 ****
--- 578,593 ----
  	    mode));
  	INTOFF;
+ 	if (mode == FORK_FG) {
+ 	        oldsigquit = signal(SIGQUIT, SIG_IGN);
+                 oldsigint = signal(SIGINT, SIG_IGN);
+ 		oldsigs_valid = 1;
+ 	}
  	pid = fork();
  	if (pid == -1) {
+ 		if (oldsigs_valid) {
+ 			signal(SIGQUIT, oldsigquit);
+ 			signal(SIGINT, oldsigint);
+ 			oldsigs_valid = 0;
+ 			}
  		TRACE(("Fork failed, errno=%d\n", errno));
  		INTON;
***************
*** 587,590 ****
--- 600,607 ----
  
  		TRACE(("Child shell %d\n", getpid()));
+ 		if (oldsigquit != SIG_IGN)
+ 			signal(SIGQUIT,SIG_DFL);
+ 		if (oldsigint != SIG_IGN)
+ 			signal(SIGINT,SIG_DFL);
  		wasroot = rootshell;
  		rootshell = 0;
***************
*** 701,704 ****
--- 718,727 ----
  		dowait(1, jp);
  	}
+ 	if (oldsigs_valid) {
+ 	       signal(SIGQUIT, oldsigquit);
+ 	       signal(SIGINT, oldsigint);
+ 	       oldsigs_valid = 0;
+ 	}
+ 
  #if JOBS
  	if (jp->jobctl) {

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980210151257.23319>