Bug #51930 [Opn->Wfx]: die() returns exit code 0
| From: | aharvey@php.net | Date: | Fri, 28 May 2010 05:49:50 +0000 |
| Subject: | Bug #51930 [Opn->Wfx]: die() returns exit code 0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-150901@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51930&edit=1
ID: 51930
Updated by: aharvey@php.net
Reported by: ml at vulnscan dot org
Summary: die() returns exit code 0
-Status: Open
+Status: Wont fix
Type: Bug
Package: Unknown/Other Function
Operating System: Linux
PHP Version: 5.3.2
New Comment:
I agree that it doesn't seem terribly logical, but it's been the case
for a good ten years or so at this point, so I can't really see the exit
code changing now.
Previous Comments:
------------------------------------------------------------------------
[2010-05-27 14:15:05] ml at vulnscan dot org
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 this bug report at http://bugs.php.net/bug.php?id=51930&edit=1