A process has a 'fork' call after a signal handler has been registered [for SIGINT]. what happens when SIGINT is sent through command line ? whether parent gets exited or child or both ? parent and child both are running infinite while loops.
If you do fork
(without further exec*
) after a signal handler has been registered, the same signal handler will be used in parent and child processes. That is, if you do something other than exit
in your SIGINT
handler, neither parent nor child will exit (how SIGINT
was sent is irrelevant here).
If you mean a SIGINT
sent from the terminal (by vintr
character which is usually Ctrl+C
): it will be received by processes using the terminal as controlling terminal. That is, unless you detach child or parent from controlling terminal, both will react to Ctrl+C
by calling your SIGINT
handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With