My question is about signals and handling them inside the operating system kernel.
I know that every process has it own
signal_handler() table: a 31 bit array for signals (
pending_signals), and when a signal arrives, do_signal() is invoke, and it calls to the relevant
signal_handler() routine, which is running in the user mode and not in the kernel mode (why is that by the way?).
Let's suppose process got some signal i.e. some bit in his signal array is on, who is writing it to this array (I guess it is the process that invoked the signal — the process that we are currently in it's context), therefore, the flow is as follows:
A invokes signal and writes it to
B's signal array (before returning to user mode?) Then in the same context (without switching to B) the specific signal handler of this signal of
B's is invoked (when do we switch to user mode?) and after we return to
A and check if it needs rescheduling and continue…
Second thing is what is happening when the signal is
SIG_CHILD, I suppose that it should occur somewhere in
do_exit() that is invoked by the child process.
And last thing is how does
waitpid(pid_t num) work?
How does the father ignore all the
SIG_CHILD signals from its other sons and care only for specific son?
If there is good source for reading the following stuff it will be great (didn't find such).