Date: Sun, 8 Sep 2002 20:15:33 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Garrett Wollman <wollman@lcs.mit.edu> Cc: jmallett@FreeBSD.ORG, <arch@FreeBSD.ORG> Subject: Re: CFR: signalinfo(3) Message-ID: <20020908195306.N2533-100000@gamplex.bde.org> In-Reply-To: <200209071711.g87HBLxO048550@khavrinen.lcs.mit.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <signal handler called> % #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^(<number of SA_ flags> + <number of signal bits>) 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020908195306.N2533-100000>