Issue is initially documented there : https://github.com/centreon/centreon-nsclient-build/issues/28
NSClient++ does not properly kill all processes spawned by an external command, after timeout has been reached.
It only kills the parent process, leaving child processes hanging forever (which can be dangerous in terms of memory consumption etc...).
Lets' take for example the following nsclient.ini configuration :
[/settings/external scripts]
timeout=10
And an external command calling centreon_plugins.exe.
When the external command is launched by NSClient++, 2 new centreon_plugins.exe appear on the Windows machine, one parent, and one child.
If the child hangs, for whatever reason, timeout will be reached, and NSClient++ will kill the parent process.
But then the child process will hang forever.
Hi,
Issue and Steps to Reproduce
Issue is initially documented there : https://github.com/centreon/centreon-nsclient-build/issues/28 NSClient++ does not properly kill all processes spawned by an external command, after timeout has been reached. It only kills the parent process, leaving child processes hanging forever (which can be dangerous in terms of memory consumption etc...).
Lets' take for example the following
nsclient.ini
configuration :And an external command calling
centreon_plugins.exe
.When the external command is launched by NSClient++, 2 new
centreon_plugins.exe
appear on the Windows machine, one parent, and one child. If the child hangs, for whatever reason,timeout
will be reached, and NSClient++ will kill the parent process. But then the child process will hang forever.Expected Behavior
NSClient++ should kill the whole processes' tree. I think it could be done there : https://github.com/mickem/nscp/blob/0.5.2.41/include/process/execute_process_w32.cpp#L246 Instead of
TerminateProcess(pi.hProcess, ...
, and then instead of working on the first / parent process only, the whole process tree should rather be proceeded. Some guideline here : https://stackoverflow.com/questions/1173342/terminate-a-process-tree-c-for-windowsDetails
Thank you 👍