瀏覽代碼

Send Control-C to the right window.

We were always trying to send Control-C to the console of the parent
process rather than any subprocesses found in kill_process_tree().
Iain Patterson 10 年之前
父節點
當前提交
11226a6ddf
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 3 3
      process.cpp
  2. 1 1
      process.h

+ 3 - 3
process.cpp

@@ -151,7 +151,7 @@ int kill_process(nssm_service_t *service, HANDLE process_handle, unsigned long p
 
   /* 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;
   }
 
   /*
@@ -186,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;
@@ -195,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) {

+ 1 - 1
process.h

@@ -14,7 +14,7 @@ int get_process_exit_time(HANDLE, FILETIME *);
 int check_parent(TCHAR *, PROCESSENTRY32 *, unsigned long, FILETIME *, FILETIME *);
 int CALLBACK kill_window(HWND, LPARAM);
 int kill_threads(nssm_service_t *, kill_t *);
-int kill_console(nssm_service_t *);
+int kill_console(nssm_service_t *, kill_t *);
 int kill_process(nssm_service_t *, HANDLE, unsigned long, unsigned long);
 void kill_process_tree(nssm_service_t *, unsigned long, unsigned long, unsigned long);