Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore SIGINT signal in child process

Tags:

c

signals

I am writing a simple program in which parent and child process are alternatively printing into a file. I have managed to do this using user defined signals. Now I want to handle the SIGINT signal. Once ctrl-c is received the parent must send termination signal to child,the child should then should terminate and finally the parent should terminate.

My question is, in order to make this work properly I must catch the SIGINT signal ONLY from parent and IGNORE it from child. Is it right? If yes any hints on doing this?

like image 469
Spyros Avatar asked Oct 18 '12 11:10

Spyros


1 Answers

Call:

signal(SIGINT, SIG_IGN);

from the child process which will make the child process ignore the SIGINT signal. From man signal:

If the disposition is set to SIG_IGN, then the signal is ignored.

like image 173
hmjd Avatar answered Oct 17 '22 22:10

hmjd