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

前端 未结 20 1756
难免孤独
难免孤独 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:58

    You edited your question, but you may still be missing the point that your question is a syntax error of sorts -- if the process wasn't put in the background to begin with and you want the PID to stay the same, you can't ignore the fact that the program which started the process is waiting on that PID and that is pretty much the definition of being in the foreground.

    I think you need to think about why you want to both put something in the background and keep the PID the same. I suggest you probably don't need both of those constraints.

提交回复
热议问题