Re: [PATCH] Bug #30743 - proc_close() causes a handle leak

From: Date: Wed, 10 Nov 2004 16:22:10 +0000
Subject: Re: [PATCH] Bug #30743 - proc_close() causes a handle leak
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-13812@lists.php.net to get a copy of this message
Hi Antony, Makes sense to me, however, what about TerminateProcess() in PHP_FUNCTION(proc_terminate)? As far as I recall (don't take my word for it), TerminateProcess() closes the handle for you, am I missing something? Can it break things on future releases of the OS? Thanks! On Wed, 10 Nov 2004 19:08:18 +0300, Antony Dovgal <tony2001@phpclub.net> wrote: > On Wed, 10 Nov 2004 17:49:45 +0200 > > > "ilya77@gmail.com" <ilya77@gmail.com> wrote: > > > Hi Guys, > > > > PHP_FUNCTION(proc_close) doesn't have a call to > > CloseHandle(proc->child), to close the process handle. > > This is causing a handle leak on Windows, and eventually brings the > > whole OS to it's knees. > > > > Here's the fixed code snippet (there's a DIFF at the end of the file): > > > > CloseHandle(proc->child);// ilya.1.0 20041110 > > First of all, this will work only under M$ systems and there are > plenty of others, that will be broken by your patch. > Second, handles are destroyed by proc_open_rsrc_dtor(), so I'd > propose the patch below instead: > > Index: proc_open.c > =================================================================== > RCS file: /repository/php-src/ext/standard/proc_open.c,v > retrieving revision 1.29 > diff -u -r1.29 proc_open.c > --- proc_open.c 29 Sep 2004 06:04:36 -0000 1.29 > +++ proc_open.c 10 Nov 2004 16:03:32 -0000 > @@ -219,6 +219,7 @@ > WaitForSingleObject(proc->child, INFINITE); > GetExitCodeProcess(proc->child, &wstatus); > FG(pclose_ret) = wstatus; > + CloseHandle(proc->child); > > #elif HAVE_SYS_WAIT_H > > -- > Wbr, > Antony Dovgal aka tony2001 > tony2001@phpclub.net || antony@dovgal.com >

« previous php.internals (#13812) next »