Edit report at https://bugs.php.net/bug.php?id=61873&edit=1
ID: 61873
User updated by: dcb at insomniacsoft dot com
Reported by: dcb at insomniacsoft dot com
Summary: proc_get_status always returns exitcode -1
Status: Open
Type: Bug
Package: Program Execution
Operating System: Linux
PHP Version: 5.4.1
Block user comment: N
Private report: N
New Comment:
Well, that is returning the proper exit code.
It's strange that nobody else can reproduce this while I have it happening on 2
different Ubuntu machines. One is a 10.04 and the other one is 11.10.
I was thinking that it might be something else, but keep in mind that on the
same
machine php 5.3 does work properly and returns the correct exit code in all the
tests.
Previous Comments:
------------------------------------------------------------------------
[2012-05-01 00:28:56] phpmpan at mpan dot pl
"and you the code is executing it. In other"
should be:
"and the code is executing it. In the other"
Sorry
------------------------------------------------------------------------
[2012-05-01 00:27:25] phpmpan at mpan dot pl
Since no one was able to reproduce this to this point, all that can be done is
debugging it somehow on your side and eliminate possible reasons.
What strace output tells us here is that "/tmp/te" actually exists and you the
code is executing it. In other case the second call to `execve` would not
return 0. If it is returning 0, it means that the interpretation of "/tmp/te"
has actually started.
He's my output for comparison (snaps for 5.4 and trunk):
-------------------------------
[pid 7359] execve("/bin/sh", ["sh", "-c", "/tmp/te"], [/* 47 vars */]
<unfinished ...>
[pid 7359] execve("/tmp/te", ["/tmp/te"], [/* 46 vars */]) = 0
[pid 7359] open("/tmp/te", O_RDONLY) = 3
write(1, "/tmp/te", 7/tmp/te) = 7
-------------------------------
What is puzzling me is why your `sh` (pid:26199) is not replacing itself with
the script. As we can see, another process (pid:26200) is spawned and it is the
one that executes your script. My blind guess is that PHP receives status code
from 26199, which - for some reason - is not waiting for 26200 or not passing
the status code from it properly.
Can you check what is this producing?
-------------------------------
sh -c /tmp/te
echo $?
-------------------------------
Maybe the bug is not in PHP...
------------------------------------------------------------------------
[2012-04-30 23:24:42] dcb at insomniacsoft dot com
Still getting -1 for /bin/ls as well
I did the strace, here is output, unfortunately I have no idea how to interpret
it:
[pid 26199] execve("/bin/sh", ["sh", "-c", "/tmp/te"], [/* 19 vars */]
<unfinished
...>
[pid 26200] execve("/tmp/te", ["/tmp/te"], [/* 19 vars */]) = 0
[pid 26200] open("/tmp/te", O_RDONLY) = 3
write(1, "/tmp/te", 7/tmp/te) = 7
------------------------------------------------------------------------
[2012-04-29 06:36:21] phpmpan at mpan dot pl
Maybe strace shows something interesting?
strace -f php -r '$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("file", "/tmp/error-output.txt", "a")
);
$p = proc_open("/tmp/te", $descriptorspec, $pipes, "/tmp");
sleep(1);
fclose($pipes[0]);fclose($pipes[1]);
$s = proc_get_status($p);
print_r($s);' 2>&1 | grep '/tmp/te'
------------------------------------------------------------------------
[2012-04-29 03:51:46] [email protected]
what about call "/bin/ls" instead of /tmp/te?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=61873
--
Edit this bug report at https://bugs.php.net/bug.php?id=61873&edit=1