I write C application that calls fork()
to create child processes. The application runs as root. In the parent process, I use wait()
for waiting terminated child processes. In child processes, I use prctl()
with PR_SET_PDEATHSIG
option to detect the death of the parent. It works fine. To reduce the risk of security issues, child processes call setuid()
to change UID. The problem is: child processes can not detect the death of the parent one any more.
I have searched around to find the answer and found some useful links, but it does not help:
- Detect death of parent process
- Enforcing process hierarchies (
prctl
related) : although this link contains a clear answer, there is no solution.
How to do that correctly?