From 48db714fa2f5c31a8bb2c227d4d0e1133284c933 Mon Sep 17 00:00:00 2001 From: Jan Dubois Date: Sat, 2 Aug 2003 03:25:05 -0700 Subject: Re: win32.c bug - handle leak Message-ID: <9gsnivssuml394bttjb3mfsmdgfn9l6kh9@4ax.com> p4raw-id: //depot/perl@20455 --- win32/win32.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'win32') 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) { -- cgit v1.2.1