On Mon, Nov 14, 2016 at 04:04:04PM -0500, Shware Systems wrote: > Technically, it doesn't > match. The #defines after provide matching labels for symbolic references, so > portable source most likely will compile, but using a field not listed for an > si_code value (with an intent of temporary storage, perhaps, rather than > increase the frame size for automatic variables) risks overwriting values > that are pertinent to that code, or reading invalid values. The method can > save space for packed allocations, usually "a good thing", at the expense of > precluding some forms of algorithm optimizations.
The spec says that all members must be part of the structure. It does't mean that they each need unique storage _at the same time_. Only the fields relevent to the signal that caused siginfo_t to be presented to the application need be valid for that signal. Note that Unix and linux systems have used a union to represent this for many years. scott > > On Monday, November 14, 2016 FELLIN, JEFF K (JEFF) (JEFF) > <j...@research.att.com> wrote: > > As I read this information from signal.h : > > ?? > > [CX] The <signal.h> header shall define the siginfo_t type as a structure, > which shall include at least the following members: > > [CX] > int???????????????????? si_signo ??Signal number. > int???????????????????? si_code?? ??Signal code. > > [XSI] > int???????????????????? si_errno ??If non-zero, an errno value associated > with > ????????????????????????????????????????????????this signal, as described in > <errno.h>. > > [CX] > pid_t???????????????? si_pid???? ??Sending process ID. > uid_t???????????????? si_uid???? ??Real user ID of sending process. > void???????????????? *si_addr?? ??Address of faulting instruction. > int???????????????????? si_status Exit value or signal. > > [OB XSR] > long?????????????????? si_band?? ??Band event for SIGPOLL. > > [CX] > union sigval?? si_value ??Signal value. > > ?? > ?? > > All of the above members MUST be available in all occurrences of siginfo_t, > whether or not they are applicable on a specific signal. > > ?? > > So can someone tell me how this siginfo_t definition matches the minimum set > of members for ALL instances of siginfo_t? > > ?? > > typedef struct siginfo > > ?? { > > ?????? int si_signo;???????????????????????????? /* Signal number.?? */ > > ?????? int si_errno;???????????????????????????? /* If non-zero, an errno > value associated with > > ???????????????????????????????????????????????????????????????????? this > signal, as defined in <errno.h>.?? */ > > ?????? int si_code;?????????????????????????????? /* Signal code.?? */ > > ?? > > ?????? union > > ?????????? { > > ?????????????? int _pad[__SI_PAD_SIZE]; > > ?? > > ???????????????? /* kill().?? */ > > ?????????????? struct > > ?????????????????? { > > ?????????????????????? __pid_t si_pid;???????? /* Sending process ID.?? */ > > ?????????????????????? __uid_t si_uid;???????? /* Real user ID of sending > process.?? */ > > ?????????????????? } _kill; > > ?? > > ?????????????? /* POSIX.1b timers.?? */ > > ?????????????? struct > > ?? ????????????????{ > > ?????????????????????? int si_tid;???????????????? /* Timer ID.?? */ > > ?????????????????????? int si_overrun;???????? /* Overrun count.?? */ > > ?????????????????????? sigval_t si_sigval; /* Signal value.?? */ > > ?????????????????? } _timer; > > ?? > > ?????????????? /* POSIX.1b signals.?? */ > > ?????????????? struct > > ?????????????????? { > > ???????????????? ??????__pid_t si_pid;???????? /* Sending process ID.?? */ > > ?????????????????????? __uid_t si_uid;???????? /* Real user ID of sending > process.?? */ > > ?????????????????????? sigval_t si_sigval; /* Signal value.?? */ > > ?????????????????? } _rt; > > ?? > > ?????????????? /* SIGCHLD.?? */ > > ?????????????? struct > > ?????????????????? { > > ?????????????????????? __pid_t si_pid;???????? /* Which child.?? */ > > ?????????????????????? __uid_t si_uid;???????? /* Real user ID of sending > process.?? */ > > ?????????????????????? int si_status;?????????? /* Exit value or signal.?? */ > > ?????????????????????? __clock_t si_utime; > > ?????????????????????? __clock_t si_stime; > > ???????????? ??????} _sigchld; > > ???????????? /* SIGILL, SIGFPE, SIGSEGV, SIGBUS.?? */ > > ?????????????? struct > > ?????????????????? { > > ?????????????????????? void *si_addr;?????????? /* Faulting insn/memory > ref.?? */ > > ?????????????????? } _sigfault; > > ?? > > ?????????????? /* SIGPOLL.?? */ > > ?????????????? struct > > ?????????????????? { > > ?????????????????????? long int si_band;???? /* Band event for SIGPOLL.?? */ > > ?????????????????????? int si_fd; > > ?????????????????? } _sigpoll; > > ?????????? } _sifields; > > ?? } siginfo_t; > > ?? > > ?? > > /* X/Open requires some more fields with fixed names.?? */ > > # define si_pid???????????????? _sifields._kill.si_pid > > # define si_uid???????????????? _sifields._kill.si_uid > > # define si_timerid???????? _sifields._timer.si_tid > > # define si_overrun???????? _sifields._timer.si_overrun > > # define si_status?????????? _sifields._sigchld.si_status > > # define si_utime???????????? _sifields._sigchld.si_utime > > # define si_stime???????????? _sifields._sigchld.si_stime > > # define si_value???????????? _sifields._rt.si_sigval > > # define si_int???????????????? _sifields._rt.si_sigval.sival_int > > # define si_ptr???????????????? _sifields._rt.si_sigval.sival_ptr > > # define si_addr?????????????? _sifields._sigfault.si_addr > > # define si_band?????????????? _sifields._sigpoll.si_band > > # define si_fd?????????????????? _sifields._sigpoll.si_fd > > ?? > > Jeff Fellin >