Subject: Re: Sane exit from a program on receipt of a signal
To: None <tech-userlevel@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-userlevel
Date: 07/18/2007 10:14:12
On Wed, 18 Jul 2007, Luke Mewburn wrote:
> /* Reset to default signal handler, clear mask, raise signal */
> memset(&act, 0, sizeof(act));
> act.sa_handler = SIG_DFL;
> if ((sigemptyset(&act.sa_mask) == 0) &&
> (sigemptyset(&mask) == 0) &&
> (sigaddset(&mask, sig) == 0) &&
> (sigaction(sig, &act, NULL) == 0) &&
> (sigprocmask(SIG_UNBLOCK, &mask, 0) == 0))
> raise(sig);
So if sigaction() succeeds but sigprocmask() fails, we don't
raise(sig). Would it be more useful to raise(sig) regardless of
whether sigprocmask() succeeds?
--apb (Alan Barrett)