unix - Linux - Handle process termination -
i need watch process known pid in linux. once terminated want execute command reason of termination.
questions
- how subscribe process health rather polling (e.g. watch command)?
- where inject event handler in os' user space?
- how detect termination/failure reason inside handler?
note
- the process intend keep tab on not forked child process of parent through can monitored.
- the process type generic (good number of them daemons)
the way kind of control on process, use ptrace(2) trace target process. use ptrace(ptrace_attach, pid)
attach process, after become target process's parent (and can use wait
or more ptrace
calls figure out process doing).
Comments
Post a Comment