summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authorJan Dubois <jand@activestate.com>2003-08-02 03:25:05 -0700
committerJarkko Hietaniemi <jhi@iki.fi>2003-08-03 18:47:13 +0000
commit48db714fa2f5c31a8bb2c227d4d0e1133284c933 (patch)
tree438d55880da2ca43981b87d6001fc1a241f45c6d /win32/win32.c
parent46c6a8acd76ad6e00cf925b19fff0f796d786c93 (diff)
downloadperl-48db714fa2f5c31a8bb2c227d4d0e1133284c933.tar.gz
Re: win32.c bug - handle leak
Message-ID: <9gsnivssuml394bttjb3mfsmdgfn9l6kh9@4ax.com> p4raw-id: //depot/perl@20455
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/win32/win32.c b/win32/win32.c
index beabef6b02..98fbea0d04 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1067,6 +1067,7 @@ win32_kill(int pid, int sig)
dTHX;
HANDLE hProcess;
long child;
+ int retval;
#ifdef USE_ITHREADS
if (pid < 0) {
/* it is a pseudo-forked child */
@@ -1125,25 +1126,29 @@ win32_kill(int pid, int sig)
}
else {
alien_process:
+ retval = -1;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE,
(IsWin95() ? -pid : pid));
if (hProcess) {
switch(sig) {
case 0:
/* "Does process exist?" use of kill */
- return 0;
+ retval = 0;
+ break;
case 2:
if (GenerateConsoleCtrlEvent(CTRL_C_EVENT,pid))
- return 0;
+ retval = 0;
break;
default: /* For now be backwards compatible with perl5.6 */
case 9:
- if (TerminateProcess(hProcess, sig)) {
- CloseHandle(hProcess);
- return 0;
- }
+ if (TerminateProcess(hProcess, sig))
+ retval = 0;
+ break;
}
}
+ CloseHandle(hProcess);
+ if (retval == 0)
+ return 0;
}
}
errno = EINVAL;
@@ -2082,6 +2087,7 @@ alien_process:
if (hProcess) {
win32_msgwait(aTHX_ 1, &hProcess, timeout, &waitcode);
if (waitcode == WAIT_TIMEOUT) {
+ CloseHandle(hProcess);
return 0;
}
else if (waitcode == WAIT_OBJECT_0) {