exit retcode ignored when called from a register_shutdown_function
| Bug #23509 | exit retcode ignored when called from a register_shutdown_function | ||||
|---|---|---|---|---|---|
| Submitted: | 2003-05-06 11:58 UTC | Modified: | 2003-08-01 07:29 UTC | ||
| From: | ldemailly at qualys dot com | Assigned: | iliaa (profile) | ||
| Status: | Closed | Package: | CGI/CLI related | ||
| PHP Version: | 4.3.2RC3-dev | OS: | Linux 2.4.20 | ||
| Private report: | No | CVE-ID: | None | ||
[2003-05-06 11:58 UTC] ldemailly at qualys dot com
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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2003-08-01 07:29 UTC] iliaa@php.net