The main process in my program forks 3 more process with say process ids as pid1, pid2, pid3. Pid1 and pid2 processes are in infinite loop. What I want is when pid3 process is over all the process including the main are terminated. As of now, I am using :
wait(pid3);
kill(0, SIGKILL);
which do all above as i said, but it prints Killed on the terminal. I don't want the signal to display killed and infact nothing, but gracefully exits from the program. How can I do that?
改用SIGTERM
,并安装一个在接收SIGTERM
执行干净出口(例如exit(0)
)的信号处理程序。
另一种方法是在进程之间设置pipe()
,并让pid1和pid2进程在其管道上看到文件结束时退出。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.