Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 fork 和 execv 来生成子程序。如何让这些程序在后台运行?我试着不等他们,但他们仍然将输出发送到屏幕。
将 stdout/stderr 重定向到/dev/null执行之前:
/dev/null
freopen("/dev/null", "w", stdout); freopen("/dev/null", "w", stderr); exec....
您可以使用管道重定向子进程的输出。看看这个问题。有代码将 stdout 和 stderr 重定向到管道。