Subject: Re: CVS commit: src/bin/sh (trap.c:1.32)
To: None <current-users@netbsd.org>
From: Geoff Wing <mason@primenet.com.au>
List: current-users
Date: 07/15/2005 02:32:52
Christos Zoulas <christos@astron.com> typed:
: In article <slrndd6hhq.rr.mason@g.primenet.com.au>,
: Geoff Wing  <mason@primenet.com.au> wrote:
:>Christos Zoulas <christos@netbsd.org> typed:
:>: Modified Files:
:>: 	src/bin/sh: trap.c
:>: Log Message:
:>: Don't hard ignore signals that were ignored by our environment, because
:>: when we try to set a trap on them it will not work. Also while I am here:

I think this will need to be dependent upon whether or not we're an
interactive shell.  Scanning through an old POSIX document I have lying
around:

3.14.13  trap ...
...
 Signals that were ignored on entry to a noninteractive shell cannot be
 trapped or reset, although no error need be reported when attempting to
 do so.  An interactive shell may reset or catch signals ignored on entry.


Maybe something along these lines plus adjusted comments and whatever, and
maybe better checking for whether we're interactive or not.

--- /usr/src/bin/sh/trap.c	2005-07-11 12:38:42.000000000 +1000
+++ trap.c	2005-07-15 12:25:26.000000000 +1000
@@ -289,7 +289,10 @@
 			 * signal. This is what other shells do, so we
 			 * do not set S_HARD_IGN here.
 			 */
-			tsig = S_IGN;
+			if (iflag)
+				tsig = S_IGN;
+			else
+				tsig = S_HARD_IGN;
 		} else {
 			tsig = S_RESET;	/* force to be set */
 		}

Regards,
Geoff