Subject: Re: Sane exit from a program on receipt of a signal
To: NetBSD User-Level Technical Discussion List <tech-userlevel@NetBSD.org>
From: Greg A. Woods <woods@planix.com>
List: tech-userlevel
Date: 07/26/2007 13:24:15
--pgp-sign-Multipart_Thu_Jul_26_13:24:14_2007-1
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

At Wed, 25 Jul 2007 16:46:15 +1000, Luke Mewburn wrote:
Subject: Re: Sane exit from a program on receipt of a signal
>=20
> Here's a minor rewrite of my 2nd attempt, based on some
> feedback I received privately from a friend.
> Changes:
>=20
>  * Highlight that memset() isn't technically async safe per signal(7).
>    I thought about removing it entirely, but as you & I chatted
>    privately, memset() should be safe. (why wouldn't it be??)
>    I want to avoid C99 features to zero it.
>    The function should be portable to other platforms,
>    which means we shouldn't assume BSD extensions like
>    sigaction.sa_sigaction are present to explicitly zero.
>    OTOH, autoconf can solve that problem :)
>=20
>  * (Temporarily) block the signal whilst we set the default handler.
>=20
>  * Raise the signal and then unblock it.
>=20
> I've also renamed it to 'raise_default_signal()'

I never liked the name "raise" to be used in conjunction with Unix-like
signals for some reason.....  (maybe I just don't like the gratuitous
API changes and inventions that ANSI C took it upon itself to foist upon
the world)

In any case as a very minor suggestions I think it would be better
(cleaner, clearer, and a tiny bit more efficient) to use kill() directly
instead of wrapping it with raise().

--=20
						Greg A. Woods

H:+1 416 218-0098 W:+1 416 489-5852 x122 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>       Secrets of the Weird <woods@weird.com>

--pgp-sign-Multipart_Thu_Jul_26_13:24:14_2007-1
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
MessageID: jhGtVdDpFg4tD3q5BqSBy+lIK0vNCt+K

iQA/AwUBRqjYvmZ9cbd4v/R/EQKisgCeMSk6j5taOSs9Wg1qP37L77FeSIYAoIsn
KO9u0yWTFieGEpSovXiEfDMl
=4X+5
-----END PGP SIGNATURE-----

--pgp-sign-Multipart_Thu_Jul_26_13:24:14_2007-1--