note 102479 added to function.proc-open
| From: | aserg45atNOSPAMyahoo-YOUKNOW-com at osu1 dot php dot net | Date: | Thu, 17 Feb 2011 07:00:07 +0000 |
| Subject: | note 102479 added to function.proc-open | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177055@lists.php.net to get a copy of this message | ||
Elaborating on what php at keith tyler dot com said on 16-Apr-2010 06:32:
Not only must you store the return value:
<?php
$proc=proc_open(....);
?>
But you must also keep it 'alive' in the current scope.
Example:
<?php
function openproc()
{
$proc=proc_open("php -f childscript.php", array(), $tmp);
echo "Opened process.\n";
return TRUE;
}
openproc();
echo "The child process is running!";
?>
The first message "Opened process." will be displayed and then.....PHP will hang until the
child process dies. Because at the "return TRUE;" statement, the $proc variable (holding
the return value from proc_open() ) goes out of the current scope.
Since the return value from proc_open() is no longer accessible, PHP strangely hangs. The second
message "The child process is running!" will not be displayed until AFTER the child
process has terminated.
Tested with PHP 5.2.7.
----
Server IP: 69.147.83.197
Probable Submitter: 98.16.181.164
----
Manual Page -- http://www.php.net/manual/en/function.proc-open.php
Edit -- https://master.php.net/note/edit/102479
Del: integrated -- https://master.php.net/note/delete/102479/integrated
Del: useless -- https://master.php.net/note/delete/102479/useless
Del: bad code -- https://master.php.net/note/delete/102479/bad+code
Del: spam -- https://master.php.net/note/delete/102479/spam
Del: non-english -- https://master.php.net/note/delete/102479/non-english
Del: in docs -- https://master.php.net/note/delete/102479/in+docs
Del: other reasons-- https://master.php.net/note/delete/102479
Reject -- https://master.php.net/note/reject/102479
Search -- https://master.php.net/manage/user-notes.php