X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=service.cpp;h=53ee349a3fe3c02dcb62f7b7e08d8e62252e22b5;hb=2994e17c24d8a3d32937a92733ba1ee0f26dc33d;hp=1c82a38ae8d4c52c6b50b645e0000277c604b447;hpb=3509063391d4180797926408610608051a8ad626;p=nssm.git diff --git a/service.cpp b/service.cpp index 1c82a38..53ee349 100644 --- a/service.cpp +++ b/service.cpp @@ -1213,7 +1213,7 @@ int control_service(unsigned long control, int argc, TCHAR **argv) { } else { CloseHandle(service_handle); - _ftprintf(stderr, _T("%s: %s %s"), canonical_name, service_control_text(control), error_string(error)); + _ftprintf(stderr, _T("%s: %s: %s"), canonical_name, service_control_text(control), error_string(error)); return 1; } } @@ -1473,8 +1473,8 @@ unsigned long WINAPI service_control_handler(unsigned long control, unsigned lon case NSSM_SERVICE_CONTROL_ROTATE: log_service_control(service->name, control, true); - if (service->rotate_stdout_online) service->rotate_stdout_online = NSSM_ROTATE_ONLINE_ASAP; - if (service->rotate_stderr_online) service->rotate_stderr_online = NSSM_ROTATE_ONLINE_ASAP; + if (service->rotate_stdout_online == NSSM_ROTATE_ONLINE) service->rotate_stdout_online = NSSM_ROTATE_ONLINE_ASAP; + if (service->rotate_stderr_online == NSSM_ROTATE_ONLINE) service->rotate_stderr_online = NSSM_ROTATE_ONLINE_ASAP; return NO_ERROR; } @@ -1539,7 +1539,7 @@ int start_service(nssm_service_t *service) { if (get_process_creation_time(service->process_handle, &service->creation_time)) ZeroMemory(&service->creation_time, sizeof(service->creation_time)); - close_output_handles(&si, ! service->rotate_stdout_online, ! service->rotate_stderr_online); + close_output_handles(&si); if (service->affinity) { /* @@ -1612,6 +1612,8 @@ int stop_service(nssm_service_t *service, unsigned long exitcode, bool graceful, service->wait_handle = 0; } + service->rotate_stdout_online = service->rotate_stderr_online = NSSM_ROTATE_OFFLINE; + if (default_action && ! exitcode && ! graceful) { log_event(EVENTLOG_INFORMATION_TYPE, NSSM_EVENT_GRACEFUL_SUICIDE, service->name, service->exe, exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_REALLY], 0); graceful = true; @@ -1659,6 +1661,8 @@ void CALLBACK end_service(void *arg, unsigned char why) { service->stopping = true; + service->rotate_stdout_online = service->rotate_stderr_online = NSSM_ROTATE_OFFLINE; + /* Check exit code */ unsigned long exitcode = 0; TCHAR code[16];