Bug #17538 Updated: proc_close() doesn't return exit value of process
| From: | kims at contrail dot com dot au | Date: | Fri, 31 May 2002 04:16:59 +0000 |
| Subject: | Bug #17538 Updated: proc_close() doesn't return exit value of process | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-8976@lists.php.net to get a copy of this message | ||
ID: 17538
Updated by: kims@contrail.com.au
Reported By: kims@contrail.com.au
Status: Open
Bug Type: Filesystem function related
Operating System: Debian GNU/Linux
PHP Version: 4.0CVS-2002-05-30
New Comment:
For what it's worth, this problem also occurrs when php is compiled
with --enable-sigchild.
Previous Comments:
------------------------------------------------------------------------
[2002-05-30 21:19:15] kims@contrail.com.au
proc_close() seems to always return -1, instead of the exit value of
the process it closed. I feel that this a bug in proc_close().
If proc_close() is returning -1 because of some sort of error or
problem, then the online manual (http://www.php.net/proc_close) needs
to specify what conditions make proc_close return -1.
Here's a script that reproduces the problem.
Thanks :)
<?
/* costants to use with the $pipes array */
define(BASH_STDIN, 0);
define(BASH_STDOUT, 1);
/* a random exit code, just to keep things interesting */
$bashexit = rand(100, 199);
/* a shell script to write to bash's STDIN */
$shellscript .=
"
echo I am bash, and I will return an exit code of $bashexit
exit $bashexit
";
/* run bash, with pipes to/from stdin and stdout */
$bash = proc_open(
"bash",
array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("file", "/tmp/bashstderr", "a")
),
$pipes
);
/* write the prepared shell script to bash's STDIN */
fwrite($pipes[BASH_STDIN], $shellscript);
/* close pipe to bash's STDIN */
fclose($pipes[BASH_STDIN]);
echo "bash's stdout:\n";
/* read and echo output from bash, one byte at a time */
while(!feof($pipes[BASH_STDOUT]))
echo fread($pipes[BASH_STDOUT], 1);
/* close pipe from bash's STDOUT */
fclose($pipes[BASH_STDOUT]);
echo "\n";
$realexit = proc_close($bash);
echo "bash's exit code: $realexit\n\n";
if ($realexit != $bashexit)
echo "process exit code was $bashexit proc_close() returned
$realexit!\n";
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17538&edit=1