Ignore SIGINT signal in child process

纵饮孤独 提交于 2019-12-05 15:02:42

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/12953350/ignore-sigint-signal-in-child-process

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!