From 2d1226f8479378969c42109cfc37becd6306867d Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Wed, 7 Sep 2016 15:12:42 +0100 Subject: [PATCH] Don't leak hook startup handles. When sharing I/O settings we dup the service's I/O handles then call CreateProcess() to run the hook. However we didn't explicitly close the duplicated handles, so the subsequent CloseHandle() called by cleanup_loggers() would hang, as the logging thread's ReadFile() won't have completed due to the duplicated handle still being a potential writer. --- hook.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hook.cpp b/hook.cpp index 6671d3b..abe4577 100644 --- a/hook.cpp +++ b/hook.cpp @@ -356,6 +356,7 @@ int nssm_hook(hook_thread_t *hook_threads, nssm_service_t *service, TCHAR *hook_ #endif ret = NSSM_HOOK_STATUS_NOTRUN; if (CreateProcess(0, cmd, 0, 0, inherit_handles, flags, 0, service->dir, &si, &pi)) { + close_output_handles(&si); hook->name = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, HOOK_NAME_LENGTH * sizeof(TCHAR)); if (hook->name) _sntprintf_s(hook->name, HOOK_NAME_LENGTH, _TRUNCATE, _T("%s (%s/%s)"), service->name, hook_event, hook_action); hook->process_handle = pi.hProcess; -- 2.7.4