Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Jul 2020 20:53:56 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r363057 - head/bin/sh
Message-ID:  <202007092053.069KruGl047187@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Thu Jul  9 20:53:56 2020
New Revision: 363057
URL: https://svnweb.freebsd.org/changeset/base/363057

Log:
  sh: Do not ignore INTOFF during a trap
  
  INTOFF postpones SIGINT processing and INTON enables it again. This is
  important so an interactive shell can return to the top level prompt when
  Ctrl+C is pressed.
  
  Given that INTON is automatically done when a builtin completes, the part
  where onsig() ignores suppressint when in_dotrap is true is both unnecessary
  and unsafe. If the trap is for some other signal than SIGINT, arbitrary code
  could have been interrupted.
  
  Historically, INTOFF remained in effect for longer.
  
  Reviewed by:	bdrewery
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D25270

Modified:
  head/bin/sh/trap.c

Modified: head/bin/sh/trap.c
==============================================================================
--- head/bin/sh/trap.c	Thu Jul  9 19:11:57 2020	(r363056)
+++ head/bin/sh/trap.c	Thu Jul  9 20:53:56 2020	(r363057)
@@ -382,12 +382,7 @@ onsig(int signo)
 {
 
 	if (signo == SIGINT && trap[SIGINT] == NULL) {
-		/*
-		 * The !in_dotrap here is safe.  The only way we can arrive
-		 * here with in_dotrap set is that a trap handler set SIGINT to
-		 * SIG_DFL and killed itself.
-		 */
-		if (suppressint && !in_dotrap)
+		if (suppressint)
 			SET_PENDING_INT;
 		else
 			onint();



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