Allow skipping kill_process_tree().
[nssm.git] / registry.cpp
index 6c1567c..bf2ddc5 100644 (file)
@@ -79,6 +79,8 @@ int create_parameters(nssm_service_t *service, bool editing) {
   else if (editing) RegDeleteValue(key, NSSM_REG_KILL_WINDOW_GRACE_PERIOD);\r
   if (service->kill_threads_delay != NSSM_KILL_THREADS_GRACE_PERIOD) set_number(key, NSSM_REG_KILL_THREADS_GRACE_PERIOD, service->kill_threads_delay);\r
   else if (editing) RegDeleteValue(key, NSSM_REG_KILL_THREADS_GRACE_PERIOD);\r
+  if (! service->kill_process_tree) set_number(key, NSSM_REG_KILL_PROCESS_TREE, 0);\r
+  else if (editing) RegDeleteValue(key, NSSM_REG_KILL_PROCESS_TREE);\r
   if (service->stdin_path[0] || editing) {\r
     if (service->stdin_path[0]) set_expand_string(key, NSSM_REG_STDIN, service->stdin_path);\r
     else if (editing) RegDeleteValue(key, NSSM_REG_STDIN);\r
@@ -649,6 +651,14 @@ int get_parameters(nssm_service_t *service, STARTUPINFO *si) {
   override_milliseconds(service->name, key, NSSM_REG_KILL_WINDOW_GRACE_PERIOD, &service->kill_window_delay, NSSM_KILL_WINDOW_GRACE_PERIOD, NSSM_EVENT_BOGUS_KILL_WINDOW_GRACE_PERIOD);\r
   override_milliseconds(service->name, key, NSSM_REG_KILL_THREADS_GRACE_PERIOD, &service->kill_threads_delay, NSSM_KILL_THREADS_GRACE_PERIOD, NSSM_EVENT_BOGUS_KILL_THREADS_GRACE_PERIOD);\r
 \r
+  /* Try to get process tree settings - may fail. */\r
+  unsigned long kill_process_tree;\r
+  if (get_number(key, NSSM_REG_KILL_PROCESS_TREE, &kill_process_tree, false) == 1) {\r
+    if (kill_process_tree) service->kill_process_tree = true;\r
+    else service->kill_process_tree = false;\r
+  }\r
+  else service->kill_process_tree = true;\r
+\r
   /* Try to get default exit action. */\r
   bool default_action;\r
   service->default_exit_action = NSSM_EXIT_RESTART;\r