Analyze the structure of the process signal queue

xiaoxiao2021-03-06  84

Each process has a signal queue described by a SIGPENDING structure. It has three members. Head points to the first SigQueue member, Tail pointing to the NEXT pointer of the last Sigqueue member, Signal describes the signal set in this queue .Static int send_signal (int sig, struct siginfo * info, struct sigpending * signals); and the corresponding signal sig info message structure added to the signal in the signal queue .static int collect_signal (int sig, struct sigpending * list, siginfo_t * info); returns Information INFO in the queue List in the queue.

struct task_struct {... struct sigpending pending; ...}; struct sigpending {struct sigqueue * head, ** tail; sigset_t signal;}; struct sigqueue {struct sigqueue * next; siginfo_t info;}; // kernel / signal .cstatic int send_signal (int sig, struct siginfo * info, struct sigpending * signals) {struct sigqueue * q = NULL; / * Real-time signals must be queued if sent by sigqueue, or some other real-time mechanism It is. implementation defined whether kill () does so. We attempt to do so, on the principle of least surprise, but since kill is not allowed to fail with EAGAIN when low on memory we just make sure at least one signal gets delivered and do not pass on the info struct * / if (atomic_read (& nr_queued_signals) next = null; * signals-> tail = q; sign-> tail = & q-> next; tail always pointing to the NEXT pointer to the last signal member Switch (unsigned long) {case 0: // info parameter is 0, indicating that the signal is derived from the current user process Q-> info.si_signo = SIG; Q-> info.si_ERRNO = 0; Q-> Info. Si_code = si_user; q-> info.si_pid = current-> pid; q-> info.si_uid = current-> uid; break; case 1: // info parameter If 1, the signal is derived from the kernel itself Q-> INFO.SI_SIGNO = SIG; Q-> Info.si_errno = 0; Q-> Info.si_code = Si_kernel; Q-> Info.si_PID = 0; Q-> Info.si_UID = 0; Break; Default: / / Otherwise Copy signal copy_siginfo in the INFO pointer; Break;}} else if (SIG> = Sigrtmin && info& (unsigned long) info! = 1 && info-> si_code! =

转载请注明原文地址:https://www.9cbs.com/read-106499.html

New Post(0)