Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External commands not properly killed after timeout #712

Open
UrBnW opened this issue Dec 31, 2020 · 2 comments
Open

External commands not properly killed after timeout #712

UrBnW opened this issue Dec 31, 2020 · 2 comments

Comments

@UrBnW
Copy link

UrBnW commented Dec 31, 2020

Hi,

Issue and Steps to Reproduce

Issue is initially documented there : centreon/centreon-nsclient-build#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.

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-windows

Details

  • NSClient++ version: 0.5.2.41
  • OS and Version: Windows (all versions)
  • Checking from: Centreon Plugins using NSClient++ new RestAPI.

Thank you 👍

@wil7nk
Copy link

wil7nk commented Aug 1, 2024

Hi, finaly did you found a solution your problem?

@UrBnW
Copy link
Author

UrBnW commented Aug 1, 2024

Unfortunately no 😕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants