ID: 33828 User updated by: vesely at tana dot it Reported By: vesely at tana dot it Status: Wont fix Bug Type: Unknown/Other Function Operating System: Unix PHP Version: 4.4.0 New Comment:
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... ?> Previous Comments: ------------------------------------------------------------------------ [2005-07-22 23:15:22] [EMAIL PROTECTED] It's fixed in 5.x, but I don't think that the fix will get into 4.4.0 ever, as it was just a small part of exec()/proc_open() overall rewrite. So I'd say you have to live with that (or use 5.x instead, this is a perfect reason to start using it). ------------------------------------------------------------------------ [2005-07-22 20:33:13] 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... ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33828&edit=1