Moved console functions to a new file.
[nssm.git] / service.cpp
index e8a1569..e9fd109 100644 (file)
@@ -1546,6 +1546,8 @@ int start_service(nssm_service_t *service) {
 \r
   close_output_handles(&si);\r
 \r
+  if (! service->no_console) FreeConsole();\r
+\r
   /* Restore our environment. */\r
   duplicate_environment(service->initial_env);\r
 \r
@@ -1697,8 +1699,6 @@ void CALLBACK end_service(void *arg, unsigned char why) {
   if (service->pid) kill_process_tree(service, service->pid, exitcode, service->pid);\r
   service->pid = 0;\r
 \r
-  if (! service->no_console) FreeConsole();\r
-\r
   /*\r
     The why argument is true if our wait timed out or false otherwise.\r
     Our wait is infinite so why will never be true when called by the system.\r