[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] trap -p does not display ignored signals inherited from pare

From: Siddhesh Poyarekar
Subject: Re: [PATCH] trap -p does not display ignored signals inherited from parent by a bash process
Date: Fri, 26 Mar 2010 01:02:01 +0530

On Thu, Mar 25, 2010 at 8:13 PM, Eric Blake <address@hidden> wrote:
> Subshells are different than new shells on what POSIX requires for
> signal manipulations.  Again, quoting POSIX:
> "When a subshell is entered, traps that are not being ignored are set to
> the default actions. This does not imply that the trap command cannot be
> used within the subshell to set new traps."
> That is, if a non-interactive parent inherited a signal ignored, then
> neither the parent nor the subshell can change it.  But if a
> non-interactive parent inherits a default signal, then explicitly
> ignores it, then subshells will inherit it ignored but can still reset
> it back to default.

I do this:

In a terminal, execute a script which does basically this:

trap '' SIGTERM

According to the above explanation, the resultant bash prompt I get on
execution of this script will allow me to override the ignored SIGTERM
since it was set in its non-interactive parent. But that is not what
happens. I cannot override SIGTERM regardless of whether the parent
shell is interactive or not. But if I replace SIGTERM with SIGHUP, it
works the way you mentioned. The reason for this seems to be the way
the GETORIGSIG macro is defined:

#define GETORIGSIG(sig) \
  do { \
    original_signals[sig] = (SigHandler *)set_signal_handler (sig, SIG_DFL); \
    set_signal_handler (sig, original_signals[sig]); \
    if (original_signals[sig] == SIG_IGN) \
      sigmodes[sig] |= SIG_HARD_IGNORE; \
  } while (0)

So any signal that GETORIGSIG is called for and is inherited as
ignored from parent will automatically be hard ignored. Due to this,
we get automatically hard ignored SIGTERM, SIGQUIT, SIGINT and SIGCHLD
whenever these signals are inherited as ignored.

It doesn't look as though the hard ignore belongs in GETORIGSIG.

Siddhesh Poyarekar

reply via email to

[Prev in Thread] Current Thread [Next in Thread]