I have a program which fork
s a child.
I am trying to catch following signals: SIGINT
, SIGPIPE
and SIGTERM
.
On Ctrl+c (which generates SIGINT - afaik) I want to make sure I kill the child process before main program terminates which I am doing in my signal handler.
Now my expectation/understanding is that parent process will be automatically be killed on Ctrl+c. But that is not happening.
On Ctrl+c I get the shell prompt back but I can still see my process in ps
. So basically my main program is not getting killed.
Is my understanding wrong?
Edit 0: One observation: Before Ctrl+c, in ps
main program status says S
but after Ctrl+c its I
.