From: David Bremner Date: Mon, 4 Jul 2016 21:36:19 +0000 (-0700) Subject: CreateToolhelp32Snapshot returns INVALID_HANDLE_VALUE on failure https://msdn.microso... X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=eed3860f97880967f2a6b92c18c0c6631d8a74b4;p=nssm.git CreateToolhelp32Snapshot returns INVALID_HANDLE_VALUE on failure https://msdn.microsoft.com/en-us/library/windows/desktop/ms682489(v=vs.85).aspx --- diff --git a/process.cpp b/process.cpp index 1c6946a..22e5a12 100644 --- a/process.cpp +++ b/process.cpp @@ -115,7 +115,7 @@ int kill_threads(nssm_service_t *service, kill_t *k) { /* Get a snapshot of all threads in the system. */ HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); - if (! snapshot) { + if (snapshot == INVALID_HANDLE_VALUE) { log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_CREATETOOLHELP32SNAPSHOT_THREAD_FAILED, k->name, error_string(GetLastError()), 0); return 0; } @@ -309,7 +309,7 @@ void kill_process_tree(nssm_service_t * service, kill_t *k, unsigned long ppid) /* Get a snapshot of all processes in the system. */ HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (! snapshot) { + if (snapshot == INVALID_HANDLE_VALUE) { log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_CREATETOOLHELP32SNAPSHOT_PROCESS_FAILED, k->name, error_string(GetLastError()), 0); return; }