How to wait for exit of non-children processes

前端 未结 9 2416
生来不讨喜
生来不讨喜 2020-11-27 18:45

For child processes, the wait() and waitpid() functions can be used to suspends execution of the current process until a child has exited. But t

9条回答
  •  情话喂你
    2020-11-27 19:32

    You could attach to the process with ptrace(2). From the shell, strace -p PID >/dev/null 2>&1 seems to work. This avoid the busy-waiting, though it will slow down the traced process, and will not work on all processes (only yours, which is a bit better than only child processes).

提交回复
热议问题