#23509 [NEW]: exit retcode ignored when called from a register_shutdown_function
From: ldemailly at qualys dot com
Operating system: Linux 2.4.20
PHP version: 4.3.2RC1
PHP Bug Type: CGI related
Bug description: exit retcode ignored when called from a register_shutdown_function
exit retcode ignored when called from a register_shutdown_function :
Trying to install an exit handler that will check
some conditions to determine the proper exit code
for a PHP shell (CLI) script (unit test, used in
Makefile, should fail if someone in the tested code
somewhere call die("..."))
I found that the exit(status) call within the handler
ignores the status argument and sticks with the original
one; this obviously makes the ability to register a shutdown
function useless for my purpose (any idea on a workaround ?)
repro script:
<?php
function exit_override() {
echo "should exit with 1\n";
exit(1);
}
register_shutdown_function("exit_override");
die("calling die...");
?>
testing:
$ php ExitBug.php ; echo $?
calling die...should exit with 1
0
***
zero instead of the expected 1
I guess, if die("string") would actually imply exit(1) I wouldn't need
this workaround, but either way it seems that the last exit call should
override the shell return status code.
Thanks
Laurent
--
Edit bug report at http://bugs.php.net/?id=23509&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23509&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23509&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23509&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23509&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23509&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23509&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23509&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23509&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23509&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23509&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23509&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23509&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23509&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23509&r=gnused
Thread (4 messages)
- ldemailly at qualys dot com