Ignore SIGINT signal in child process

38,250

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.

Share:
38,250

Related videos on Youtube

Author by

Spyros

Updated on October 19, 2020

Comments

  • Spyros about 2 years

    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?

  • Spyros about 10 years
    Ok i know the SIG_IGN action,but i want ONLY the child to ignore that and when the parent catches the signal,terminate the child.
  • hmjd
    hmjd about 10 years
    @SpyrosR, so only have the child call it?
  • Spyros about 10 years
    Yes.I have set two handling functions,one for parent for catching the signal and sending SITERM signal to child and one for child for ignoring the signal but i cant make it work.If for example press ctrl-c while child is "working" it does call the child handle function but it does also call the parent handle function for the SIGINT signal.

Related