Bug #62725 [NEW]: Calling exit() in a shutdown function does not return the exit value
From: ospite at studenti dot unina dot it
Operating system: Debian GNU/Linux
PHP version: 5.4.5
Package: CGI/CLI related
Bug Type: Bug
Bug description:Calling exit() in a shutdown function does not return the exit value
Description:
------------
Calling exit() in a shutdown function behaves differently between php 5.3
and php 5.4 (I tested with the latest stable release 5.4.5 too).
The behavior I expect is that the value returned to the calling process is
the one from the last exit() in a shutdown function, and php 5.3 honors
that assumption, while php 5.4 does not.
As a side note, the documentation[1] tells only that calling exit() in a
shutdown function blocks executing further shutdown functions but it does
not make clear what the returned value will be.
[1] http://www.php.net/register_shutdown_function
Test script:
---------------
<?php
# This script behaves differently between php 5.3 and php 5.4
# Test it with php command line:
# $ php test_exit_in_shutdown_function.php; echo $?
function shutdown()
{
echo 'Script executed with failure', PHP_EOL;
exit(1);
}
register_shutdown_function('shutdown');
exit(0);
Expected result:
----------------
The return value is the one from the exit() inside the last shutdown
function, this is the php 5.3 behavior:
$ php test_exit_in_shutdown_function.php; echo $?
Script executed with failure
1
Actual result:
--------------
In php 5.4.5 the return value from the exit() inside the shutdown function
is ignored:
$ php test_exit_in_shutdown_function.php; echo $?
Script executed with failure
0
--
Edit bug report at https://bugs.php.net/bug.php?id=62725&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62725&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62725&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62725&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62725&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62725&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62725&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62725&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62725&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62725&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62725&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62725&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62725&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62725&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62725&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62725&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62725&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62725&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62725&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62725&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62725&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62725&r=mysqlcfg
Thread (2 messages)
- ospite at studenti dot unina dot it