Is there a way to know the value passed to exit()
from within a shutdown function?
For example:
<?php
function handleShutdown(){
// Is there a way to know the value passed to exit() at this point?
someCleanup();
}
register_shutdown_function('handleShutdown');
if(somethingWentWrong()){
exit(3);
}
exit(0);
This is in the context of a complex set of legacy scripts running in CLI mode. I am looking for a solution to instrument their exit status within php that does not involve modifying all the points where the scripts invoke exit()
(so, not using a global variable, define
or forking the whole script).
There is this other SO question asking to know whether the exit was is "clean", but it does not address the exit code at all.