Reputation: 954
As part of sending interrupts to user space I am seeing the following code snippet around but I don't understand how si_int
affects the signal propagation.
static int SendToUsrSpace(void) {
struct siginfo info;
struct task_struct *t;
int ret;
memset(&info, 0, sizeof(struct siginfo));
info.si_signo = 44;
info.si_code = SI_QUEUE;
info.si_int = 1234; // WHY NOT 36 or any random number?
[...]
ret = send_sig_info(44, &info, t);
[...]
}
Upvotes: 2
Views: 975
Reputation: 423
I think the explanation is in sigqueue(3). From the text:
sigqueue() sends the signal specified in sig to the process whose PID
is given in pid. The permissions required to send a signal are the
same as for kill(2). As with kill(2), the null signal (0) can be
used to check if a process with a given PID exists.
The value argument is used to specify an accompanying item of data
(either an integer or a pointer value) to be sent with the signal,
and has the following type:
union sigval {
int sival_int;
void *sival_ptr;
};
If the receiving process has installed a handler for this signal
using the SA_SIGINFO flag to sigaction(2), then it can obtain this
data via the si_value field of the siginfo_t structure passed as the
second argument to the handler. Furthermore, the si_code field of
that structure will be set to SI_QUEUE.
So, 1234 looks like an arbitrary value that a process can pull (if it has a handler for this signal). It looks like a way to send data with the signal.
Additional reading: I arrived at sigqueue from sigaction(2), which lays out the data type for siginfo_t.
Upvotes: 1