The question is now, how do you proceed with this issue? Can you fix it anytime soon? Thank you very much!
I don't think it is normal that the zombie processes remain forever. Every single call causes a new defunct process! There is an kernel PID limit as well. If the limit is reached the run script mechanism will stop working. For Debian the default is about 15000. I ran into this and that was when I noticed the problem. The only workaround so far is to restart the kea process which is really annoying.
that's right. Name is truncated by ps
ok, haven't turned multi-threading on. How can I check the status?
Using the default kernel shipped with Debian (Buster) and RedHat (7, 8)
The zombies remain forever. Only stopping kea kills all zombies
@razvan kea-dhcp-nsupdate-hook.sh
is indeed the script called by kea (see config above). I tried different interpreter (bash, sh, zsh, ksh, ...), same result. Even simple test scripts, like the one below, cause zombies. The test script just consists of one line:
#!/bin/sh
The exit code suppossed to be 0, nothing to be worried about. To my understanding the script becomes a zombie when the task has completed but the parent process (kea) is either gone or is not able to receive the SIGCHLD signal (the execution status is not collected by the parent).
I guess multi-threading is enabled by default?
Thanks @andrei for your very informative answer! Is the synchronous support expected to be implemented in the near future?
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!