How to Spawn Child Processes that Don't Die with Parent?

前端 未结 6 1199
说谎
说谎 2021-01-18 11:09

I have a C++ program that acts as a watchdog over others. If it detects that a process is no longer running, it restarts it via system. The problem is, if I kil

6条回答
  •  广开言路
    2021-01-18 11:55

    You may be interested by the daemon(3) library function (internally using two nested fork(2) syscalls). After that, use the relevant execve(2) syscall (or related exec(3) functions)...

    You should read Advanced Linux Programming for more.

提交回复
热议问题