Subject: Re: Sane exit from a program on receipt of a signal
To: None <tech-userlevel@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
Date: 07/25/2007 10:52:45
> * 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.
If you want it portable to other platforms, you cannot assume that
memset zeros anything but integer types. However, since you're already
setting every member of sigaction, why memset it? (sa_sigaction is
overlaid onto sa_handler - are there systems with sa_sigaction which
don't overlay it?)
I also note that, if the signal doesn't kill the process, the routine
returns with the handler set to SIG_DFL and the signal unblocked,
regardless of the state of those on entry. If it's left like this I
think those need to be very clearly called out in the doc.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML firstname.lastname@example.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B