Fix kill(0, $pid) on Windows
authorJan Dubois <jand@activestate.com>
Mon, 16 Apr 2007 17:35:48 +0000 (10:35 -0700)
committerSteve Hay <SteveHay@planit.com>
Tue, 17 Apr 2007 11:13:23 +0000 (11:13 +0000)
From: "Jan Dubois" <jand@activestate.com>
Message-ID: <01df01c78088$59718d30$0c54a790$@com>

Fixes breakage caused by #29605.

p4raw-id: //depot/perl@30970

win32/win32.c

index 4337256..55239e5 100644 (file)
@@ -1218,7 +1218,7 @@ kill_process_tree_toolhelp(DWORD pid, int sig)
     int killed = 0;
 
     process_handle = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
-    if (process_handle == INVALID_HANDLE_VALUE)
+    if (process_handle == NULL)
         return 0;
 
     killed += terminate_process(pid, process_handle, sig);
@@ -1253,7 +1253,7 @@ kill_process_tree_sysinfo(SYSTEM_PROCESSES *process_info, DWORD pid, int sig)
     int killed = 0;
 
     process_handle = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
-    if (process_handle == INVALID_HANDLE_VALUE)
+    if (process_handle == NULL)
         return 0;
 
     killed += terminate_process(pid, process_handle, sig);
@@ -1308,7 +1308,8 @@ my_kill(int pid, int sig)
         return killpg(pid, -sig);
 
     process_handle = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
-    if (process_handle != INVALID_HANDLE_VALUE) {
+    /* OpenProcess() returns NULL on error, *not* INVALID_HANDLE_VALUE */
+    if (process_handle != NULL) {
         retval = terminate_process(pid, process_handle, sig);
         CloseHandle(process_handle);
     }