Linux signals with extra information parameter

163 Views Asked by At

I was to have some extra information in the callback to sa_sigaction handler, it does not seems possible.

So I was wondering if you could suggest me alternatives. Basic requirements:

  1. Function A raises an signal/event with a pointer to a struct
  2. Handler function tackles the event.
  3. The handler function would only be called on an event and a loop to wait for the event, as in select() , is undesirable.
1

There are 1 best solutions below

0
On

like this ?

    int sigqueue(pid_t to_pid, int signr, const union sigval pointer_or_int);

and on the other end:

   int signr=int sigwaitinfo(const sigset_t *set, siginfo_t *info);

Warning!: passing by reference might not work between different address/process spaces (I haven't tested this myself yet) so first test this between threads of the same process....

good luck :-)