Skip some or all methods of stopping the application.
[nssm.git] / service.cpp
index 21726df..873b8a8 100644 (file)
@@ -12,6 +12,7 @@ char flags[CMD_LENGTH];
 char dir[MAX_PATH];\r
 bool stopping;\r
 unsigned long throttle_delay;\r
+unsigned long stop_method;\r
 HANDLE throttle_timer;\r
 LARGE_INTEGER throttle_duetime;\r
 FILETIME creation_time;\r
@@ -372,7 +373,7 @@ int start_service() {
 \r
   /* Get startup parameters */\r
   char *env = 0;\r
-  int ret = get_parameters(service_name, exe, sizeof(exe), flags, sizeof(flags), dir, sizeof(dir), &env, &throttle_delay, &si);\r
+  int ret = get_parameters(service_name, exe, sizeof(exe), flags, sizeof(flags), dir, sizeof(dir), &env, &throttle_delay, &stop_method, &si);\r
   if (ret) {\r
     log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_GET_PARAMETERS_FAILED, service_name, 0);\r
     return stop_service(2, true, true);\r
@@ -431,7 +432,7 @@ int stop_service(unsigned long exitcode, bool graceful, bool default_action) {
   if (pid) {\r
     /* Shut down service */\r
     log_event(EVENTLOG_INFORMATION_TYPE, NSSM_EVENT_TERMINATEPROCESS, service_name, exe, 0);\r
-    kill_process(service_name, process_handle, pid, 0);\r
+    kill_process(service_name, stop_method, process_handle, pid, 0);\r
   }\r
   else log_event(EVENTLOG_INFORMATION_TYPE, NSSM_EVENT_PROCESS_ALREADY_STOPPED, service_name, exe, 0);\r
 \r
@@ -480,7 +481,7 @@ void CALLBACK end_service(void *arg, unsigned char why) {
   }\r
 \r
   /* Clean up. */\r
-  kill_process_tree(service_name, pid, exitcode, pid, &creation_time, &exit_time);\r
+  kill_process_tree(service_name, stop_method, pid, exitcode, pid, &creation_time, &exit_time);\r
 \r
   /*\r
     The why argument is true if our wait timed out or false otherwise.\r