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):

------------- cut here -------------
/* {{{ proto int proc_close(resource process)
   close a process opened by proc_open */
PHP_FUNCTION(proc_close)
{
zval *zproc;
struct php_process_handle *proc;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zproc) ==
FAILURE) {
RETURN_FALSE;
}

ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, &zproc, -1,
"process", le_proc_open);

CloseHandle(proc->child);// ilya.1.0 20041110

zend_list_delete(Z_LVAL_P(zproc));
RETURN_LONG(FG(pclose_ret));
}
/* }}} */
------------- cut here -------------

Index: php-src/ext/standard/proc_open.c
===================================================================
RCS file: /repository/php-src/ext/standard/proc_open.c,v
retrieving revision 1.29
diff -r1.29 proc_open.c
90c90
<       
---
> 
94c94
<       
---
> 
96c96
<       
---
> 
110c110
<               
---
> 
116c116
<               
---
> 
118c118
<               
---
> 
137c137
<               
---
> 
140c140
<               
---
> 
144c144
<               
---
> 
155c155
<                               
---
> 
173c173
<       }       
---
>       }
176c176
<       
---
> 
216c216
<       
---
> 
218c218
<       
---
> 
222c222
<       
---
> 
224c224
<       
---
> 
228c228
<       
---
> 
236c236
<       
---
> 
243c243
<       
---
> 
264c264
<       
---
> 
266c266
<       
---
> 
282c282
<       
---
> 
324c324
<       
---
> 
330c330
<       
---
> 
332a333,334
> 
>       /* should use this? if a handle leak occurs - should */ // 
> CloseHandle(proc->child);    // ilya.1.0 20041110
336c338
<       
---
> 
348c350
<       
---
> 
354c356,358
<       
---
> 
>       CloseHandle(proc->child);       // ilya.1.0 20041110
> 
374c378
<       
---
> 
385c389
<       
---
> 
387c391
<       
---
> 
392c396
<       
---
> 
394c398
<       
---
> 
397c401
<       
---
> 
433c437
<       
---
> 
518c522
<               }       
---
>               }
520c524
<       
---
> 
538c542
<       
---
> 
621a626
> 
630c635
<                               
---
> 
710c715
<       
---
> 
714c719
<       
---
> 
730c735
<       
---
> 
732c737
<       
---
> 
739c744
<       
---
> 
745c750
<       
---
> 
778c783
<               
---
> 
800c805
<               
---
> 
804c809
<               
---
> 
924a930
> 
930c936
<                                       
---
>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to