From owner-freebsd-questions Thu Apr 5 14:56:24 2001 Delivered-To: freebsd-questions@freebsd.org Received: from dsl-64-193-218-89.telocity.com (dsl-64-193-218-89.telocity.com [64.193.218.89]) by hub.freebsd.org (Postfix) with SMTP id A44B237B43F for ; Thu, 5 Apr 2001 14:56:20 -0700 (PDT) (envelope-from lucas@slb.to) Received: (qmail 6347 invoked by uid 1000); 5 Apr 2001 21:56:38 -0000 Date: Thu, 5 Apr 2001 16:56:37 -0500 From: Lucas Bergman To: Arcady Genkin Cc: freebsd-questions@freebsd.org Subject: Re: [OT] Reinstalling signal handler inside signal handler Message-ID: <20010405165637.C18827@billygoat.slb.to> Reply-To: lucas@slb.to References: <87d7ardw5s.fsf@tea.thpoon.com> <20010405161123.A18827@billygoat.slb.to> <87vgojc9gc.fsf@tea.thpoon.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <87vgojc9gc.fsf@tea.thpoon.com>; from a.genkin@utoronto.ca on Thu, Apr 05, 2001 at 05:39:47PM -0400 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > 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. > > Lucas, thanks for your answer. For the record, it seems like Linux > does use the *BSD* sematics that you describe above. I'll be damned. The following code demonstrates that you're right: % uname -a Linux apu 2.2.16 #15 Thu Feb 15 11:12:47 CST 2001 i686 unknown % cat sig.c #include #include #include void f(int sig) { printf("signal handled\n"); } int main() { if (signal(SIGHUP, f) == SIG_ERR) { fprintf(stderr, "Blargh!\n"); exit(1); } for (;;) sleep(1); return 0; } % gcc -Wall -g -o sig sig.c % ./sig & [1] 30547 % kill -HUP 30547 signal handled % kill -HUP 30547 signal handled I'm not really a Linux person, so I was just quoting the man page, which I guess is out of date. Cheers, Lucas To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message