From owner-freebsd-questions Thu Apr 5 14:39:53 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mail.thpoon.com (cr103675-a.bloor1.on.wave.home.com [24.42.106.79]) by hub.freebsd.org (Postfix) with SMTP id 3371A37B449 for ; Thu, 5 Apr 2001 14:39:49 -0700 (PDT) (envelope-from a.genkin@utoronto.ca) Received: (qmail 11592 invoked from network); 5 Apr 2001 21:39:48 -0000 Received: from unknown (HELO tea.thpoon.com) (qmailr@192.168.1.2) by cr103675-a.bloor1.on.wave.home.com with SMTP; 5 Apr 2001 21:39:48 -0000 Received: (qmail 2873 invoked by uid 1000); 5 Apr 2001 21:39:47 -0000 To: lucas@slb.to Cc: freebsd-questions@FreeBSD.ORG Subject: Re: [OT] Reinstalling signal handler inside signal handler References: <87d7ardw5s.fsf@tea.thpoon.com> <20010405161123.A18827@billygoat.slb.to> X-Face: 0=A/O5-+sE[Tf%X>rYr?Y5LD4,:^'jaJ!4jC&UR*ZrrK2>^`g22Qeb]!:d;}2YJ|Hq"LHdF OX`jWX|AT-WVFQ(TPhFVak)0nt$aEdlOq=1~D,:\z5QlVOrZ2(H,mKg=Xr|'VlHA="r From: Arcady Genkin Date: 05 Apr 2001 17:39:47 -0400 In-Reply-To: <20010405161123.A18827@billygoat.slb.to> Message-ID: <87vgojc9gc.fsf@tea.thpoon.com> Lines: 40 User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Cuyahoga Valley) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Lucas Bergman 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 > instead of (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 #include 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