Module: check_mk
Branch: master
Commit: 70f66656b49c0fe7d6a70f249808a9f09a86d46d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=70f66656b49c0f…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Wed Apr 13 08:54:13 2016 +0200
windows agent: slight cleanup, no functional change
---
agents/windows/check_mk_agent.cc | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 3c465d3..bc289e1 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -994,13 +994,21 @@ void section_ps(OutputProxy &out) {
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hProcessSnap, &pe32)) {
+ // GetProcessHandleCount is only available winxp upwards
+ typedef BOOL WINAPI (*GetProcessHandleCount_type)(HANDLE, PDWORD);
+ GetProcessHandleCount_type GetProcessHandleCount_dyn =
+ DYNAMIC_FUNC(GetProcessHandleCount, L"kernel32.dll");
+
do {
string user = "unknown";
DWORD dwAccess = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ;
WinHandle hProcess(
OpenProcess(dwAccess, FALSE, pe32.th32ProcessID));
- if (NULL == hProcess) continue;
+ // the following isn't really necessary. We only need the
+ // process handle to determine process owner and handle count,
+ // the process list could still be useful without that.
+ if (nullptr == hProcess) continue;
// Process times
FILETIME createTime, exitTime, kernelTime, userTime;
@@ -1015,12 +1023,7 @@ void section_ps(OutputProxy &out) {
DWORD processHandleCount = 0;
- // GetProcessHandleCount is only available winxp upwards
- typedef BOOL WINAPI (*GetProcessHandleCount_type)(HANDLE,
- PDWORD);
- GetProcessHandleCount_type GetProcessHandleCount_dyn =
- DYNAMIC_FUNC(GetProcessHandleCount, L"kernel32.dll");
- if (GetProcessHandleCount_dyn != NULL) {
+ if (GetProcessHandleCount_dyn != nullptr) {
GetProcessHandleCount_dyn(hProcess, &processHandleCount);
}