How can a C/C++ program put itself into background?

前端 未结 20 1707
难免孤独
难免孤独 2020-12-09 18:16

What\'s the best way for a running C or C++ program that\'s been launched from the command line to put itself into the background, equivalent to if the user had launched fro

20条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 18:45

    I'm not sure about Windows, but on UNIX-like systems, you can fork() then setsid() the forked process to move it into a new process group that is not connected to a terminal.

提交回复
热议问题