Subject: Re: Sane exit from a program on receipt of a signal
To: Alan Barrett <apb@cequrux.com>
From: Luke Mewburn <lukem@NetBSD.org>
List: tech-userlevel
Date: 07/18/2007 20:05:48
--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Wed, Jul 18, 2007 at 10:14:12AM +0200, Alan Barrett wrote:
| 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 =3D SIG_DFL;
| > if ((sigemptyset(&act.sa_mask) =3D=3D 0) &&
| > (sigemptyset(&mask) =3D=3D 0) &&
| > (sigaddset(&mask, sig) =3D=3D 0) &&
| > (sigaction(sig, &act, NULL) =3D=3D 0) &&
| > (sigprocmask(SIG_UNBLOCK, &mask, 0) =3D=3D 0))
| > raise(sig);
|=20
| 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?
You're probably right; the code could just be simplified
to call the sig*() functions and not bother checking the
return values (except for possibly sigaction()); the function
is intended to terminate the process.
--oyUTqETQ0mS9luUI
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (NetBSD)
iD8DBQFGneX8pBhtmn8zJHIRApr7AKCqiLTqFRngH/Cs2Nfq8NcWF740oACfdT5n
+l6Tb+5q3OYx7L+BAIj7OC0=
=DoHc
-----END PGP SIGNATURE-----
--oyUTqETQ0mS9luUI--