In the case where the application crashed and NSSM then cleaned up its
child processes the events logged were confusing. First we'd log that
we were going to kill the process tree with exit code X then we'd log
that the service had ended with exit code X.
Logging that the application exited before doing the process tree kill
makes it clearer that the cleanup is in response to the application
exit.
\r
/* Check exit code */\r
unsigned long exitcode = 0;\r
\r
/* Check exit code */\r
unsigned long exitcode = 0;\r
GetExitCodeProcess(process_handle, &exitcode);\r
\r
GetExitCodeProcess(process_handle, &exitcode);\r
\r
+ /*\r
+ Log that the service ended BEFORE logging about killing the process\r
+ tree. See below for the possible values of the why argument.\r
+ */\r
+ if (! why) {\r
+ _snprintf(code, sizeof(code), "%d", exitcode);\r
+ log_event(EVENTLOG_INFORMATION_TYPE, NSSM_EVENT_ENDED_SERVICE, exe, service_name, code, 0);\r
+ }\r
+\r
/* Clean up. */\r
kill_process_tree(service_name, pid, exitcode, pid);\r
\r
/* Clean up. */\r
kill_process_tree(service_name, pid, exitcode, pid);\r
\r
*/\r
if (why) return;\r
\r
*/\r
if (why) return;\r
\r
- char code[16];\r
- _snprintf(code, sizeof(code), "%d", exitcode);\r
- log_event(EVENTLOG_INFORMATION_TYPE, NSSM_EVENT_ENDED_SERVICE, exe, service_name, code, 0);\r
-\r
/* What action should we take? */\r
int action = NSSM_EXIT_RESTART;\r
unsigned char action_string[ACTION_LEN];\r
/* What action should we take? */\r
int action = NSSM_EXIT_RESTART;\r
unsigned char action_string[ACTION_LEN];\r