开发者

Disown children from spawn process

开发者 https://www.devze.com 2023-03-23 23:28 出处:网络
I have a C application that spawns children using fork/exec. My spawn-process runs non-stop and it creates a log file using a unix pipe. Every 24 hours I want to backup the logs. For this I\'m using a

I have a C application that spawns children using fork/exec. My spawn-process runs non-stop and it creates a log file using a unix pipe. Every 24 hours I want to backup the logs. For this I'm using a script. Once the script has finished, I want to kill and restart the process. So far so good. But there might be the case that there a still spawned children active. Is it possible to disown them before killing and restarting the spawn process?

Usual开发者_JAVA百科ly, when the parent gets killed, all the children are immediately killed also.


A process doesn't just die when its parent dies. Most likely, your children processes are receiving some signal (SIGHUP ?) for some reason.

If you want your children to persist, you need to find out what that signal is and ignore it right after fork.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号