Send Control-C to the right window.
[nssm.git] / process.cpp
index 59707c4..e96265d 100644 (file)
@@ -149,16 +149,9 @@ int kill_process(nssm_service_t *service, HANDLE process_handle, unsigned long p
 
   kill_t k = { pid, exitcode, 0 };
 
-  /* Close the stdin pipe. */
-  if (service->stdin_pipe) {
-    CloseHandle(service->stdin_pipe);
-    service->stdin_pipe = 0;
-    if (! await_shutdown(service, _T(__FUNCTION__), service->kill_console_delay)) return 1;
-  }
-
   /* Try to send a Control-C event to the console. */
   if (service->stop_method & NSSM_STOP_METHOD_CONSOLE) {
-    if (! kill_console(service)) return 1;
+    if (! kill_console(service, &k)) return 1;
   }
 
   /*
@@ -193,7 +186,7 @@ int kill_process(nssm_service_t *service, HANDLE process_handle, unsigned long p
 }
 
 /* Simulate a Control-C event to our console (shared with the app). */
-int kill_console(nssm_service_t *service) {
+int kill_console(nssm_service_t *service, kill_t *k) {
   unsigned long ret;
 
   if (! service) return 1;
@@ -202,7 +195,7 @@ int kill_console(nssm_service_t *service) {
   if (! imports.AttachConsole) return 4;
 
   /* Try to attach to the process's console. */
-  if (! imports.AttachConsole(service->pid)) {
+  if (! imports.AttachConsole(k->pid)) {
     ret = GetLastError();
 
     switch (ret) {