Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 1998 16:05:47 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, cracauer@cons.org
Cc:        freebsd-current@FreeBSD.ORG
Subject:   Re: cvs commit: src/bin/sh jobs.c
Message-ID:  <199802120505.QAA03695@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
This version works bug-for-bug compatibly with bash-2 on tests 01-05.
It handles SIGINT "right".  It ignores SIGQUIT unless SIGQUIT is
trapped.

SIGQUIT handling is currently not critical for emacs, due to a bug in
the tty driver.  Emacs sets both the intr and the quit character to ^G.
I think the tty driver should generate both a SIGINT and a SIGQUIT when
^G is hit, but it only generates a SIGINT.

Another test:

	#!./testshell
	while :; cat; done

Sending a SIGINT to `cat' alone doesn't terminate bash.  The change in
jobs.c is to make it not terminate sh.

Bruce

diff -c2 error.c~ error.c
*** error.c~	Tue Apr 29 04:24:04 1997
--- error.c	Thu Feb 12 11:22:06 1998
***************
*** 90,97 ****
   * that SIGINT is to be trapped or ignored using the trap builtin, then
   * this routine is not called.)  Suppressint is nonzero when interrupts
!  * are held using the INTOFF macro.  The call to _exit is necessary because
!  * there is a short period after a fork before the signal handlers are
!  * set to the appropriate value for the child.  (The test for iflag is
!  * just defensive programming.)
   */
  
--- 90,97 ----
   * that SIGINT is to be trapped or ignored using the trap builtin, then
   * this routine is not called.)  Suppressint is nonzero when interrupts
!  * are held using the INTOFF macro.  If SIGINTs are not suppressed and
!  * the shell is not a root shell, then we want to be terminated if we
!  * get here, as if we were terminated directly by a SIGINT.  Arrange for
!  * this here.
   */
  
***************
*** 107,115 ****
  	sigemptyset(&sigset);
  	sigprocmask(SIG_SETMASK, &sigset, NULL);
! 	out2str("\n");
! 	if (rootshell && iflag)
  		exraise(EXINT);
! 	else
! 		_exit(128 + SIGINT);
  }
  
--- 107,117 ----
  	sigemptyset(&sigset);
  	sigprocmask(SIG_SETMASK, &sigset, NULL);
! 	write(STDERR_FILENO, "\n", 1);
! 	if (rootshell /* && iflag ?? */)
  		exraise(EXINT);
! 	else {
! 		signal(SIGINT, SIG_DFL);
! 		kill(getpid(), SIGINT);
! 	}
  }
  
diff -c2 jobs.c~ jobs.c
*** jobs.c~	Sun Feb  8 20:50:06 1998
--- jobs.c	Thu Feb 12 11:19:43 1998
***************
*** 726,732 ****
  	if (! JOBS || jp->state == JOBDONE)
  		freejob(jp);
! 	CLEAR_PENDING_INT;
! 	if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT)
! 		kill(getpid(), SIGINT);
  	INTON;
  	return st;
--- 726,735 ----
  	if (! JOBS || jp->state == JOBDONE)
  		freejob(jp);
! 	if (int_pending()) {
! 		if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT)
! 			kill(getpid(), SIGINT);
! 		else
! 			CLEAR_PENDING_INT;
! 	}
  	INTON;
  	return st;
diff -c2 trap.c~ trap.c
*** trap.c~	Tue Nov 11 18:15:35 1997
--- trap.c	Thu Feb 12 14:45:23 1998
***************
*** 220,228 ****
  	else
  		action = S_IGN;
! 	if (rootshell && action == S_DFL) {
  		switch (signo) {
  		case SIGINT:
! 			if (iflag)
! 				action = S_CATCH;
  			break;
  		case SIGQUIT:
--- 220,227 ----
  	else
  		action = S_IGN;
! 	if (action == S_DFL) {
  		switch (signo) {
  		case SIGINT:
! 			action = S_CATCH;
  			break;
  		case SIGQUIT:
***************
*** 235,241 ****
  			}
  #endif
! 			/* FALLTHROUGH */
  		case SIGTERM:
! 			if (iflag)
  				action = S_IGN;
  			break;
--- 234,241 ----
  			}
  #endif
! 			action = S_IGN;
! 			break;
  		case SIGTERM:
! 			if (rootshell && iflag)
  				action = S_IGN;
  			break;
***************
*** 243,247 ****
  		case SIGTSTP:
  		case SIGTTOU:
! 			if (mflag)
  				action = S_IGN;
  			break;
--- 243,247 ----
  		case SIGTSTP:
  		case SIGTTOU:
! 			if (rootshell && mflag)
  				action = S_IGN;
  			break;
***************
*** 402,406 ****
  	int on;
  {
! 	static int is_interactive = 0;
  
  	if (on == is_interactive)
--- 402,406 ----
  	int on;
  {
! 	static int is_interactive = -1;
  
  	if (on == is_interactive)

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?199802120505.QAA03695>