Hi,

I already reported this in Fedora rawhide
(https://bugzilla.redhat.com/show_bug.cgi?id=572305) This also seems
to be present upstream, so I hope you guys find this useful.

Description of problem:
trap -p doesn't show ignored signals inherited from its parent across an execve

Version-Release number of selected component (if applicable):
bash-4.1.2-3.fc14

How reproducible:
Always

Steps to Reproduce:
1. trap '' SIGINT
2. exec bash
3. trap -p

Actual results:
Nothing is returned as output of trap -p. But at the same time, running cat and
trying to interrupt it shows that the signal is in fact being ignored

Expected results:
The list of ignored signals should be returned

Additional info:
Attached patch ensures that inherited ignored signals are reflected in
trap_list and then subsequently displayed when trap -p is invoked.


-- 
Siddhesh Poyarekar
http://siddhesh.in
--- a/jobs.c	2009-11-30 03:42:05.000000000 +0530
+++ b/jobs.c	2010-03-11 00:43:59.000000000 +0530
@@ -3772,9 +3772,16 @@ set_new_line_discipline (tty)
 void
 initialize_job_signals ()
 {
+  SigHandler *old_int;
+
   if (interactive)
     {
-      set_signal_handler (SIGINT, sigint_sighandler);
+      old_int = set_signal_handler (SIGINT, sigint_sighandler);
+
+      /* If a handler has been modified or inherited, restore the old one */
+      if ( old_int != (SigHandler *)SIG_DFL )
+        set_signal_handler (SIGINT, old_int);
+
       set_signal_handler (SIGTSTP, SIG_IGN);
       set_signal_handler (SIGTTOU, SIG_IGN);
       set_signal_handler (SIGTTIN, SIG_IGN);
--- a/trap.c	2010-03-11 00:35:25.000000000 +0530
+++ b/trap.c	2010-03-11 00:41:31.000000000 +0530
@@ -142,9 +142,23 @@ initialize_traps ()
   for (i = 1; i < NSIG; i++)
     {
       pending_traps[i] = 0;
-      trap_list[i] = (char *)DEFAULT_SIG;
+      /* These will be set by initialize_signals(), but we don't want to show
+       * them in the traps list */
+      if ( i == SIGTSTP || i == SIGTTOU || i == SIGTTIN )
+        {
+	  trap_list[i] = (char *)DEFAULT_SIG;
+	}
+      else
+        {
+	  /* Don't assume that the original signal was SIG_DFL */
+	  original_signals[i] = (SigHandler *)set_signal_handler (i, SIG_DFL);
+	  set_signal_handler (i, original_signals[i]);
+
+	  trap_list[i] = (char *)original_signals[i];
+	}
       sigmodes[i] = SIG_INHERITED;
-      original_signals[i] = IMPOSSIBLE_TRAP_HANDLER;
+      if ( original_signals[i] == SIG_DFL )
+        original_signals[i] = IMPOSSIBLE_TRAP_HANDLER;
     }
 
   /* Show which signals are treated specially by the shell. */

Reply via email to