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

前端 未结 6 1197
说谎
说谎 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:46

    Try using system with setsid before the process name.

    system("setsid processname /path/to/processConfig.xml &");
    

    This will launch the program in a new session.

提交回复
热议问题