\r
/* Check exit code */\r
unsigned long exitcode = 0;\r
+ char code[16];\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
*/\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