Date: 05 Apr 2001 17:39:47 -0400 From: Arcady Genkin <a.genkin@utoronto.ca> To: lucas@slb.to Cc: freebsd-questions@FreeBSD.ORG Subject: Re: [OT] Reinstalling signal handler inside signal handler Message-ID: <87vgojc9gc.fsf@tea.thpoon.com> In-Reply-To: <20010405161123.A18827@billygoat.slb.to> References: <87d7ardw5s.fsf@tea.thpoon.com> <20010405161123.A18827@billygoat.slb.to>
next in thread | previous in thread | raw e-mail | index | archive | help
Lucas Bergman <lucas@slb.to> writes:
> Signals on "traditional" systems (V7, System V) were reset to their
> default behavior after they were raised, so the signal handler had to
> reinstall itself if it was to persist. BSD changed that; you have to
> deliberately reset a signal's behavior (excuse the split infinitive).
> Linux actually follows the old semantics, but you can include
> <bsd/signal.h> instead of <signal.h> (or call __bsd_signal() instead
> of signal()) to get the BSD semantics. Confused yet?
Lucas, thanks for your answer. For the record, it seems like Linux
does use the *BSD* sematics that you describe above. For example, the
following code works the same way on both FreeBSD and Linux.
#include <stdlib.h>
#include <signal.h>
void
handler( int sig )
{
puts( "foo" );
}
void
main(void)
{
if ( signal( SIGUSR1, handler ) == SIG_ERR )
exit(1);
while (1) {
printf( "%d\n", getpid() );
sleep(1);
}
}
So, is it better to reinstall the signal within the handler for
portabiity? It seems like it can't hurt.
--
Arcady Genkin
Nostalgia isn't what it used to be.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87vgojc9gc.fsf>
