用c在Linux上进行Im编程。在siginfo_t中,文件描述符有si_fd。我从另一个进程收到信号,并且sigwaitinfo返回有关该信号的信息。我想获取文件描述符,但没有运气。siginfo_t结构为:
siginfo_t {
int si_signo; /* Signal number */
int si_errno; /* An errno value */
int si_code; /* Signal code */
int si_trapno; /* Trap number that caused
hardware-generated signal
(unused on most architectures) */
pid_t si_pid; /* Sending process ID */
uid_t si_uid; /* Real user ID of sending process */
int si_status; /* Exit value or signal */
clock_t si_utime; /* User time consumed */
clock_t si_stime; /* System time consumed */
sigval_t si_value; /* Signal value */
int si_int; /* POSIX.1b signal */
void *si_ptr; /* POSIX.1b signal */
int si_overrun; /* Timer overrun count;
POSIX.1b timers */
int si_timerid; /* Timer ID; POSIX.1b timers */
void *si_addr; /* Memory location which caused fault */
long si_band; /* Band event (was int in
glibc 2.3.2 and earlier) */
int si_fd; /* File descriptor */
short si_addr_lsb; /* Least significant bit of address
(since Linux 2.6.32) */
void *si_lower; /* Lower bound when address violation
occurred (since Linux 3.19) */
void *si_upper; /* Upper bound when address violation
occurred (since Linux 3.19) */
int si_pkey; /* Protection key on PTE that caused
fault (since Linux 4.6) */
void *si_call_addr; /* Address of system call instruction
(since Linux 3.5) */
int si_syscall; /* Number of attempted system call
(since Linux 3.5) */
unsigned int si_arch; /* Architecture of attempted system call
(since Linux 3.5) */
}
任何帮助,谢谢
答案 0 :(得分:0)
从sigaction(2)手册页开始,其中描述了siginfo_t
结构:
发送用于消息队列通知的信号(请参阅mq_notify(3)中的SIGEV_SIGNAL的描述),将sigev_value提供给mq_notify(3)填充si_int / si_ptr; si_pid,带有消息发送者的进程ID;和si_uid,以及消息发送者的真实用户ID。
那里si_fd
一无所有。
似乎仅由SIGIO
填充:
SIGIO / SIGPOLL(这两个名称在Linux上是同义词)填充si_band和si_fd。 si_band事件是一个位掩码,其中包含与poll(2)在revents字段中填充的值相同的值。 si_fd字段指示发生了I / O事件的文件描述符;有关更多详细信息,请参见fcntl(2)中F_SETSIG的描述。