Fake stdin for applications which exit on EOF.
[nssm.git] / service.cpp
index 9cdf9de..c920af8 100644 (file)
@@ -1522,6 +1522,7 @@ int start_service(nssm_service_t *service) {
   bool inherit_handles = false;\r
   if (si.dwFlags & STARTF_USESTDHANDLES) inherit_handles = true;\r
   unsigned long flags = service->priority & priority_mask();\r
+  if (service->stdin_pipe) flags |= DETACHED_PROCESS;\r
   if (service->affinity) flags |= CREATE_SUSPENDED;\r
 #ifdef UNICODE\r
   flags |= CREATE_UNICODE_ENVIRONMENT;\r
@@ -1614,6 +1615,10 @@ int stop_service(nssm_service_t *service, unsigned long exitcode, bool graceful,
     UnregisterWait(service->wait_handle);\r
     service->wait_handle = 0;\r
   }\r
+  if (service->stdin_pipe) {\r
+    CloseHandle(service->stdin_pipe);\r
+    service->stdin_pipe = 0;\r
+  }\r
 \r
   service->rotate_stdout_online = service->rotate_stderr_online = NSSM_ROTATE_OFFLINE;\r
 \r