Detect death of parent process

前端 未结 3 1540
梦如初夏
梦如初夏 2021-01-04 11:06

How can I detect parent process death in Linux OS?

If in parent process called fork(), that create child process. In the parent process I can use system

3条回答
  •  粉色の甜心
    2021-01-04 11:41

    In my Ubuntu 16.04.1 LTS getppid() returns no "1" but id of process "/sbin/upstart --user" after parent kill, so checking getppid() == 1 will not work and getppid() should be saved at child start and later compared.

提交回复
热议问题