|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-02-04 17:54 UTC] thekid@php.net
Description: ------------ Calling exit with an int arg will not lead to PHP exiting with this exitcode. Test script: --------------- $ php -r 'exit(2);' ; echo $? Expected result: ---------------- 2 Actual result: -------------- 254 Patcheswrong_exit_code.patch (last revision 2012-02-06 09:55 UTC by laruence@php.net)patch_v1 (last revision 2012-02-04 20:40 UTC by php-dev at zerocue dot com) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 23:00:02 2025 UTC |
Your patch breaks the exitcode 254 for parse errors. We have the following cases and expected exit codes: * Clean exit, `php -r 'echo "";' ; echo $?` = 0 * Clean explicit exit with message, `php -r 'exit("test");' ; echo $?` = 0 * Clean explicit exit with exitcode, `php -r 'exit(2);' ; echo $?` = 2 * Exit after a fatal error, `php -r '$fatal->error();' ; echo $?` = 255 * Exit after compile error, `php -r '$->' ; echo $?` = 254...oh, and: * Uncaught exception exit, `php -r 'throw new Exception("test");' ; echo $?` = 255Test suite: <?php if (!isset($argv[1])) { exit("*** Usage: php exit.php /path/to/php/binary\n"); } $php= realpath($argv[1]); if (!is_executable($php)) { exit("*** PHP Binary '$argv[1]' is not executable\n"); } $tests= array( "echo '';" => 0, "exit('test');" => 0, "exit(2);" => 2, "fatal();" => 255, "\$->" => 254, "throw new Exception('test');" => 255 ); foreach ($tests as $source => $expected) { $cmd= '"'.$php.'" -r "'.$source.'" 2>&1'; $output= array(); exec($cmd, $output, $actual); if ($actual === $expected) { printf("%-30s: [OK]\n", $source); } else { printf("%-30s: [FAIL, expect %d, have %d (%s)]\n", $source, $expected, $actual, implode(' ', $output)); } } ?>