mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 03:58:20 +00:00
Improve supervisor checks for parent process termination
Comparing parent process ID to 1 to detect loss of parent process was not necessarily portable, so now it stores parent PID pre-fork and then monitors for any change.
This commit is contained in:
parent
899a987527
commit
7ddd311583
5 changed files with 101 additions and 65 deletions
10
src/Net.cc
10
src/Net.cc
|
@ -290,7 +290,15 @@ void net_run()
|
|||
while ( iosource_mgr->Size() ||
|
||||
(BifConst::exit_only_after_terminate && ! terminating) )
|
||||
{
|
||||
if ( zeek::supervised_node && getppid() == 1 )
|
||||
// Note: only simple + portable way of detecting loss of parent
|
||||
// process seems to be polling for change in PPID. There's platform
|
||||
// specific ways if we do end up needing something more responsive
|
||||
// and/or have to avoid overhead of polling, but maybe not worth
|
||||
// the additional complexity:
|
||||
// Linux: prctl(PR_SET_PDEATHSIG, ...)
|
||||
// FreeBSD: procctl(PROC_PDEATHSIG_CTL)
|
||||
// TODO: make this a proper timer
|
||||
if ( zeek::supervised_node && zeek::supervised_node->parent_pid != getppid() )
|
||||
zeek_terminate_loop("supervised cluster node was orphaned");
|
||||
|
||||
double ts;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue