From: rachmel at avaya dot com Operating system: Linux 2.6.14.7 PHP version: 5.2.6 PHP Bug Type: Other web server Bug description: exec returns the wrong status
Description: ------------ PHP's exec function returns the wrong return value. When running script from CLI, works perfectly. When running the same script from the web-server context - 90% of the times it returns the wrong value - (-1). I am using the appWeb embedded server, which is a slim apache-like webserver. I validated there are no permission running issues, and I couldn't see any log messages sent by PHP that might indicate what the problem is. Reproduce code: --------------- <?php print "<pre>"; for ($i = 0; $i < 10; ++$i) { exec("/bin/true", $output, $status); print "exec('/bin/true') returns with <b>$status</b> (expected 0)\n"; } for ($i = 0; $i < 10; ++$i) { exec("/bin/false", $output, $status); print "exec('/bin/false') returns with <b>$status</b> (expected 1)\n"; } print "</pre>"; ?> Expected result: ---------------- All executions of "true" should print "0" to the screen All executions of "false" should print "1" to the screen. Actual result: -------------- Most of the times, all executions result in an error code of "-1" being printed to the screen. -- Edit bug report at http://bugs.php.net/?id=46477&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46477&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46477&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46477&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46477&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46477&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=46477&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46477&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46477&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46477&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46477&r=support Expected behavior: http://bugs.php.net/fix.php?id=46477&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46477&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46477&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46477&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46477&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46477&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46477&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46477&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46477&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46477&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46477&r=mysqlcfg