X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=service.cpp;h=9cdf9dedd301246632b5a32252e5d44b33be1d06;hb=0f9817471a5b65eeedf1b4a892e86fb486a55807;hp=a86d74400655fd522be9773286aafcfb32eabd89;hpb=e0b8c553770cccef4d8b19396c79129eebf353d4;p=nssm.git diff --git a/service.cpp b/service.cpp index a86d744..9cdf9de 100644 --- a/service.cpp +++ b/service.cpp @@ -1214,6 +1214,9 @@ 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)); + if (error == ERROR_SERVICE_NOT_ACTIVE) { + if (control == SERVICE_CONTROL_SHUTDOWN || control == SERVICE_CONTROL_STOP) return 0; + } return 1; } } @@ -1612,6 +1615,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 +1664,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];