|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-07-22 20:33 UTC] vesely at tana dot it
Description:
------------
If the proc_open was inside a class object,
then on a fatal error the child process
is not killed. (Both CLI and Apache.)
That behaviour makes it difficult to develop
scripts based on classes using proc_open.
If the $proc is not inside a class object,
I obtained a similar freezing doing $proc = 0
before the fatal error.
Reproduce code:
---------------
<?php
class my_class
{
var $proc, $pipes;
function my_class() {
$this->proc = proc_open("cat -",
array(
0 => array("pipe", "r"),
1 => array("file", "/dev/null", "w"),
2 => array("file", "/dev/null", "w")),
$this->pipes);
}
}
$p = new my_class();
printf("%s proc hangs on fatal PHP error?\n",
is_resource($p->proc) ? "Open" : "Not open");
non_existing_function("hangs if open");
// not reached...
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 15 11:00:01 2025 UTC |
Perhaps you may check the following code, please? When migrating to 5.x we will have to review c'tors anyway, so it seems fine to me. Strange as it looks, I wouldn't bet about unwanted side effects. If you feel like recommending it, I'll post a pointer to this bug in the relevant manual page. Workaround code: ---------------- <?php class my_class { var $proc, $pipes; function my_class() { // open in c'tor hangs on fatal error // $this->open(); } function open() { $this->proc = proc_open("cat -", array( 0 => array("pipe", "r"), 1 => array("file", "/dev/null", "w"), 2 => array("file", "/dev/null", "w")), $this->pipes); $GLOBALS[uniqid("my_class_proc_open_")] = $this->proc; } } $p = new my_class(); $p->open(); printf("%s proc hangs on fatal PHP error?\n", is_resource($p->proc) ? "Open" : "Not open"); non_existing_function("does not hang: just aborts"); // not reached... ?>