Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13808 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33528 invoked by uid 1010); 10 Nov 2004 15:50:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 33501 invoked from network); 10 Nov 2004 15:50:39 -0000 Received: from unknown (HELO rproxy.gmail.com) (64.233.170.195) by pb1.pair.com with SMTP; 10 Nov 2004 15:50:39 -0000 Received: by rproxy.gmail.com with SMTP id q1so262928rnf for ; Wed, 10 Nov 2004 07:50:39 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=k6Utjc9SHq1X70sQDzwLdocYx2Q7ddicDx6j7bDYHqTYMs12u3JGQWogUNJxzVw90zhquuudOjbkboHOTSWwdJcAaKNy55HWr6708G0YSjtOMnpPmhr8aebHFti21k4r+Rau2T9j5k5HYAv7LPs42V3rtBIwiTJSRJsRu5uEmf4= Received: by 10.38.74.43 with SMTP id w43mr468672rna; Wed, 10 Nov 2004 07:49:46 -0800 (PST) Received: by 10.38.70.1 with HTTP; Wed, 10 Nov 2004 07:49:45 -0800 (PST) Message-ID: Date: Wed, 10 Nov 2004 17:49:45 +0200 Reply-To: "ilya77@gmail.com" To: internals@lists.php.net Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [PATCH] Bug #30743 - proc_close() causes a handle leak From: ilya77@gmail.com ("ilya77@gmail.com") 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 < --- >