service->rotate_stdout_online = NSSM_ROTATE_OFFLINE;\r
}\r
\r
- if (dup_handle(service->stdout_si, &si->hStdOutput, _T("stdout_si"), _T("stdout"))) {\r
- if (service->stdout_thread) {\r
- CloseHandle(service->stdout_thread);\r
- service->stdout_thread = 0;\r
- }\r
- }\r
+ if (dup_handle(service->stdout_si, &si->hStdOutput, _T("stdout_si"), _T("stdout"))) close_handle(&service->stdout_thread);\r
}\r
\r
/* stderr */\r
}\r
}\r
\r
- if (dup_handle(service->stderr_si, &si->hStdError, _T("stderr_si"), _T("stderr"))) {\r
- if (service->stderr_thread) {\r
- CloseHandle(service->stderr_thread);\r
- service->stderr_thread = 0;\r
- }\r
- }\r
+ if (dup_handle(service->stderr_si, &si->hStdError, _T("stderr_si"), _T("stderr"))) close_handle(&service->stderr_thread);\r
}\r
\r
/*\r
address = &buffer;\r
ret = try_read(logger, address, sizeof(buffer), &in, &complained);\r
if (ret < 0) {\r
- CloseHandle(logger->read_handle);\r
- CloseHandle(logger->write_handle);\r
+ close_handle(&logger->read_handle);\r
+ close_handle(&logger->write_handle);\r
HeapFree(GetProcessHeap(), 0, logger);\r
return 2;\r
}\r
/* Write up to the newline. */\r
ret = try_write(logger, address, i, &out, &complained);\r
if (ret < 0) {\r
- CloseHandle(logger->read_handle);\r
- CloseHandle(logger->write_handle);\r
+ close_handle(&logger->read_handle);\r
+ close_handle(&logger->write_handle);\r
HeapFree(GetProcessHeap(), 0, logger);\r
return 3;\r
}\r
risk losing everything.\r
*/\r
if (logger->copy_and_truncate) FlushFileBuffers(logger->write_handle);\r
- CloseHandle(logger->write_handle);\r
+ close_handle(&logger->write_handle);\r
bool ok = true;\r
TCHAR *function;\r
if (logger->copy_and_truncate) {\r
error = GetLastError();\r
log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_CREATEFILE_FAILED, logger->path, error_string(error), 0);\r
/* Oh dear. Now we can't log anything further. */\r
- CloseHandle(logger->read_handle);\r
- CloseHandle(logger->write_handle);\r
+ close_handle(&logger->read_handle);\r
+ close_handle(&logger->write_handle);\r
HeapFree(GetProcessHeap(), 0, logger);\r
return 4;\r
}\r
ret = try_write(logger, address, in, &out, &complained);\r
size += (__int64) out;\r
if (ret < 0) {\r
- CloseHandle(logger->read_handle);\r
- CloseHandle(logger->write_handle);\r
+ close_handle(&logger->read_handle);\r
+ close_handle(&logger->write_handle);\r
HeapFree(GetProcessHeap(), 0, logger);\r
return 3;\r
}\r
}\r
\r
- CloseHandle(logger->read_handle);\r
- CloseHandle(logger->write_handle);\r
+ close_handle(&logger->read_handle);\r
+ close_handle(&logger->write_handle);\r
HeapFree(GetProcessHeap(), 0, logger);\r
return 0;\r
}\r