"run script" hook leaves behind defunct/zombie processes
The "run script" hook (libdhcp_run_script.so) leaves behind defunct/zombie processes after calling the desired script.
ps aux | grep defunct
_kea 2816177 0.0 0.0 0 0 ? Z 12:27 0:00 [kea-dhcp-nsupda] <defunct>
_kea 2816269 0.0 0.0 0 0 ? Z 12:28 0:00 [kea-dhcp-nsupda] <defunct>
_kea 2816382 0.0 0.0 0 0 ? Z 12:30 0:00 [kea-dhcp-nsupda] <defunct>
_kea 2816413 0.0 0.0 0 0 ? Z 12:30 0:00 [kea-dhcp-nsupda] <defunct>
I tried on different machines and environments (Debian, RedHat, KEA 1.9.5, 1.9.6...).
My /etc/kea/kea-dhcp4.conf config (only relevant part):
"hooks-libraries": [
{
"library": "/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_stat_cmds.so"
},
{
"library": "/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_lease_cmds.so"
},
{
"library": "/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_run_script.so",
"parameters": {
"name": "/kea-dhcp-nsupdate-hook.sh",
"sync": false
}
}
],
version:
kea-dhcp4 -v
1.9.6
Could the reason be the way ProcessSpawn is called by "run_script" ? run_script.cc#L54
void
RunScriptImpl::runScript(const ProcessArgs& args, const ProcessEnvVars& vars) {
ProcessSpawn process(io_service_, name_, args, vars);
process.spawn(true);
}
pid_t
ProcessSpawnImpl::spawn(bool dismiss) {
lock_guard<std::mutex> lk(mutex_);
// Create the child
pid_t pid = fork();
if (pid < 0) {
isc_throw(ProcessSpawnError, "unable to fork current process");
} else if (pid == 0) {
// Run the executable.
execve(executable_.c_str(), args_.get(), vars_.get());
// We may end up here if the execve failed, e.g. as a result
// of issue with permissions or invalid executable name.
_exit(EXIT_FAILURE);
}
// We're in the parent process.
if (!dismiss) {
store_ = true;
process_collection_[this].insert(std::pair<pid_t, ProcessStatePtr>(pid, ProcessStatePtr(new ProcessState())));
}
return (pid);
}
Since dismiss is always set to true the process state won't be stored. If the child calls the SIGCHLD handler the parent process will not recognize. Am I totally wrong? Could someone shine light on this issue please. Thank you!
Edited by seb sch