Waitpid equivalent with timeout?

前端 未结 10 1255
小鲜肉
小鲜肉 2020-11-27 12:10

Imagine I have a process that starts several child processes. The parent needs to know when a child exits.

I can use waitpid, but then if/when the paren

10条回答
  •  春和景丽
    2020-11-27 13:04

    The function can be interrupted with a signal, so you could set a timer before calling waitpid() and it will exit with an EINTR when the timer signal is raised. Edit: It should be as simple as calling alarm(5) before calling waitpid().

提交回复
热议问题