C siginfo中的si_int是什么?它如何影响信号传播
作为向用户空间发送中断的一部分,我看到了下面的代码片段,但我不理解C siginfo中的si_int是什么?它如何影响信号传播,c,interrupt-handling,sigint,signal-handling,C,Interrupt Handling,Sigint,Signal Handling,作为向用户空间发送中断的一部分,我看到了下面的代码片段,但我不理解si_int如何影响信号传播 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_i
si_int
如何影响信号传播
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);
[...]
}
我想是的。案文如下:
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.
因此,1234看起来像一个进程可以拉取的任意值(如果它有此信号的处理程序)。这看起来像是用信号发送数据的一种方式
附加阅读:我从到达sigqueue,它列出了siginfo\u t的数据类型。发送通过
si\u int
内部中断修改的寄存器值是错误的,还是该信息嵌入了其他变量中?我想你在这里没问题——sigqueue(3)引用信号发送方确定该值,所以我把它理解为“由你决定”。那么寄存器的地址位置以及值呢,值在si_int
中,有没有办法提取地址本身?我可以看到si_addr是(void*),所以那里什么都没有。我不确定我是否遵循了。假设我们谈论的是eax/ecx/eip等,这些都没有地址;他们有地址。你能给我一个你要找的数据的例子吗?假设驱动程序检测到一个中断,当我将信号转发到用户空间时,`siginfo\u t->si\u value.sival\u int`将包含发生中断的地址的值(假设中断正在写入该地址)。我怎样才能告诉它涉及哪个地址?