Designing a monitor process for monitoring and restarting processes

前端 未结 4 1521
灰色年华
灰色年华 2020-12-19 22:33

I am designing a monitor process. The job of the monitor process is to monitor a few set of configured processes. When the monitor process detects that a process has gone do

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-19 23:40

    You can easily tell if a process is alive by issuing a kill() system call to its pid. If the child is not alive, kill() will not succeed.

    Also, calling waitpid() with the WNOHANG option will return zero immediately if the process is still alive.

    IMHO, reading proc files or piping to ps is a nasty way to do it.

提交回复
热议问题