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.
master
Iain Patterson 9 years ago
parent 62f28c55d4
commit 2d1226f847

@ -356,6 +356,7 @@ int nssm_hook(hook_thread_t *hook_threads, nssm_service_t *service, TCHAR *hook_
#endif #endif
ret = NSSM_HOOK_STATUS_NOTRUN; ret = NSSM_HOOK_STATUS_NOTRUN;
if (CreateProcess(0, cmd, 0, 0, inherit_handles, flags, 0, service->dir, &si, &pi)) { 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)); 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); 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; hook->process_handle = pi.hProcess;

Loading…
Cancel
Save