Bug #51930 [NEW]: die() returns exit code 0
| From: | ml at vulnscan dot org | Date: | Thu, 27 May 2010 12:15:09 +0000 |
| Subject: | Bug #51930 [NEW]: die() returns exit code 0 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-150874@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux
PHP version: 5.3.2
Package: Unknown/Other Function
Bug Type: Bug
Bug description:die() returns exit code 0
Description:
------------
die() returns exit status 0 (success), which is IMHO illogical.
This mostly matters when using PHP-CLI, for example where you have the
usual:
@mysql_connect(..) or die('sql blahblah');
...in that case a success error code is returned.
I had this in an authentication callback script which returns 0 on user
success and any other value on user failure.
In this case it returned 'success' in case of a SQL server error.
The only workaround I can see is first printing the error message, and then
doing an explicit die/exit with a numerical value. This does not exactly
improve code readability/niceness. And, like I said, I simply didn't expect
die() to return a success exit code.
Test script:
---------------
<? die('abc'); ?>
Expected result:
----------------
I expect a non-zero exit code, instead of 0 (success).
Actual result:
--------------
Exit status of 0 (success)
--
Edit bug report at http://bugs.php.net/bug.php?id=51930&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51930&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51930&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=51930&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=51930&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51930&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51930&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51930&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51930&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51930&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51930&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51930&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51930&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51930&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51930&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51930&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51930&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51930&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51930&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51930&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51930&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51930&r=mysqlcfg