php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48552 register_shutdown_function random behavior on different platforms after exit
Submitted: 2009-06-15 03:07 UTC Modified: 2009-06-15 08:37 UTC
From: cagret at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.9 OS: Win/Linux/Apache/Lighttpd
Private report: No CVE-ID: None
 [2009-06-15 03:07 UTC] cagret at gmail dot com
Description:
------------
Function registered with register_shutdown_function() sometimes is executed / sometimes it is not, after you exit (outside of registered function) - depends on php configuration.

Win+Apache+php5 as mod - shutdown.txt IS NOT created.
Win+Apache+php5 as cgi - shutdown.txt IS created
Win+Apache+php4 as mod - shutdown.txt IS created
Win+Lighttpd+php5 as fcgi - shutdown.txt IS created
Linux+Apache+php4 as mod - shutdown.txt IS created
Linux+Lighttpd+php5 as fcgi - shutdown.txt IS created

I've thought this is a bug on Win+Apache+php5asmod, and reported it, but jani@php.net (http://bugs.php.net/bug.php?id=48475) says it is an expected behavior: "Expected behaviour. exit() is supposed to exit immediately. Nothing is supposed to be run after you call exit."

If this is an expected behavior, then seems like there is a bug on other php configurations.

Reproduce code:
---------------
<?php
function shutdown()
{
	file_put_contents(dirname(__FILE__).'/shutdown.txt', time());
}
register_shutdown_function('shutdown');
exit();
?>

Expected result:
----------------
shutdown.txt should not be created.

Actual result:
--------------
shutdown.txt is created

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-15 08:37 UTC] jani@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Dec 09 19:00:01 2025 UTC