From owner-freebsd-arch Sun Sep 8 3: 8:10 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A770C37B400; Sun, 8 Sep 2002 03:08:04 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7395B43E42; Sun, 8 Sep 2002 03:08:03 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id UAA29092; Sun, 8 Sep 2002 20:07:56 +1000 Date: Sun, 8 Sep 2002 20:15:33 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Garrett Wollman Cc: jmallett@FreeBSD.ORG, Subject: Re: CFR: signalinfo(3) In-Reply-To: <200209071711.g87HBLxO048550@khavrinen.lcs.mit.edu> Message-ID: <20020908195306.N2533-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, 7 Sep 2002, Garrett Wollman wrote: > In article <20020907022003.A66983@FreeBSD.org> you write: > > >See, signal(3) installs handlers for the sa_handler variety of signal > >handlers, and yet this is not the only type of handler one might want > >to have, one might also want the "traditional" sa_sigaction handler > >style, which includes siginfo_t, and struct sigcontext, both of which > >are very useful, depending on the signal. > > Actually, those are new-style (POSIX Real-Time Signals) handlers. The > traditional (Standard C) style takes a single argument. The > really-old-fashioned (4.2BSD, pre-C89) handlers provided three > arguments but they weren't the same as the three arguments used in > RTS handlers and in any case we don't support that now. We still support 2 of the args of 4.2BSD handlers in a binary compatible way, at least on i386's. All signal handlers get passed extra args no matter how they are declared. 4.2BSD args: int signum, int sigcode, struct sigcontext *scp FreeBSD-old args: same FreeBSD-not-so-old args: int signum, int sigcode, struct sigcontext *scp, vm_offset_t faultaddr FreeBSD args: int signum, siginfo_t *sip, struct sigcontext *scp, vm_offset_t faultaddr In -current, SA_SIGINFO just causes sip to be non-NULL. In my test, sip pointed to not very interesting and apparently broken info: % Program received signal SIGUSR1, User defined signal 1. % 0x280a5963 in kill () from /usr/lib/libc.so.5 % (gdb) c % Continuing. % % Breakpoint 1, sig (code=30, sip=0xbfbff84c, scp=0xbfbff708, addr=0) at z.c:7 % 7 } % (gdb) where % #0 sig (code=30, sip=0xbfbff84c, scp=0xbfbff708, addr=0) at z.c:7 % #1 % #2 0x280a5963 in kill () from /usr/lib/libc.so.5 % #3 0x080484e1 in _start () % (gdb) p *sip % $1 = {si_signo = 30, si_errno = 0, si_code = 0, si_pid = 0, si_uid = 0, % si_status = 0, si_addr = 0x2, si_value = {sigval_int = 0, sigval_ptr = 0x0}, % si_band = 0, __spare__ = {0, 0, 0, 0, 0, 0, 0}} I expected at least si_pid and si_uid to be nonzero here. > >So I wrote signalinfo(3) > >which installs *those* kinds of signal handlers, no fuss. > > I'm confused. Why would you want to use this? There is already a > perfectly good interface for installing Real-Time Signal handlers, > and it's specified in the standard: sigaction(3). I don't think > that this convenience function belongs in the C library. I agree. There are approximately 2^( + ) convenience functions that can be built from sigaction(). Which ones are actually convenient is application-specific. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message