[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sigaction, SA_SIGINFO, and SIG_IGN
From: |
Paul Eggert |
Subject: |
Re: sigaction, SA_SIGINFO, and SIG_IGN |
Date: |
Thu, 19 Jun 2008 11:52:36 -0700 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
Bruno Haible <address@hidden> writes:
> if (sigaction (fatal_signals[i], NULL, &action) >= 0
> + /* POSIX says that SIG_IGN can only occur when action.sa_flags
> + does not contain SA_SIGINFO. But in Linux 2.4, for example,
> + SA_SIGINFO can actually be set and is ignored when sa_handler
> + is SIG_IGN. So don't bother testing for SA_SIGINFO. */
> && action.sa_handler == SIG_IGN)
> fatal_signals[i] = -1;
I'd feel a bit safer if we wrote the code to conform to POSIX rather
than assume the typical implementation where sa_handler and
sa_sigaction overlap. How about something like this instead?
if (sigaction (fatal_signals[i], NULL, &action) == 0
&& ((action.sa_flags & SA_SIGINFO
? (void (*) (int)) action.sa_sigaction
: action.sa_handler)
== SIG_IGN))
fatal_signals[i] = -1;
This avoids undefined behavior from the point of view of C,
while remaining portable to implementations where sa_handler
and sa_sigaction don't overlap. On typical implementations
with a good optimizing compiler, this code should run just
as fast as what's in there now.
- Re: RFC: sigaction module, (continued)
- Re: RFC: sigaction module, Paul Eggert, 2008/06/16
- Re: RFC: sigaction module, Bruno Haible, 2008/06/17
- Re: RFC: sigaction module, Eric Blake, 2008/06/17
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Bruno Haible, 2008/06/17
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Eric Blake, 2008/06/17
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Bruno Haible, 2008/06/18
- RE: sigaction, SA_SIGINFO, and SIG_IGN, Jason Zions, 2008/06/18
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Bruno Haible, 2008/06/19
- Re: Interix, Bruno Haible, 2008/06/19
- Re: sigaction, SA_SIGINFO, and SIG_IGN,
Paul Eggert <=
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Bruno Haible, 2008/06/19
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Paul Eggert, 2008/06/20
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Eric Blake, 2008/06/20
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Bruno Haible, 2008/06/20
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Eric Blake, 2008/06/21
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Bruno Haible, 2008/06/22
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Bruno Haible, 2008/06/22
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Bruno Haible, 2008/06/22
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Bruno Haible, 2008/06/22
- Re: sigaction, SA_SIGINFO, and SIG_IGN, Eric Blake, 2008/06/23