Explain the process by which the Linux kernel handles a blocked signal from arrival to unblocking. Include in your explanation the roles of sigset_t, sigpending, and sigqueue structures.
A signal is usually blocked because of the signal mask. When a signal is blocked using sigprocmask, all the occurrences of that signal are marked as pending instead of being delivered immediately. In linuc kernel, the task_struct is the kernel's representation of a process and it handles everything related to blocking and unblocking. When the signal first arrives , the kernel checks if it is blocked or not, if not blocked sent immediately to the process and if blocked, it is added to sigset_t signal in the struct sigpending. A struct sigqueue is assigned for the pending process and added to the list_head in struct sigpending. When the signal mask changes using sigprocmask,the kernel checks the pending signal, since the signal which was blocked earlier is not blocked now, so it will be deliverd to the process.