|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-08-10 13:33 UTC] herbert at groot dot jebbink dot nl
Description:
------------
The second file_put_contents to the same file inside the Shutdown function does never happen, the script hangs.
When removing the 'LOCK_EX' option it works.
The setup is a own build inside Debian Stretch inside ChromeOS (with crouton), Apache is used from the Stretch distribution.
./configure --with-apxs2=/usr/bin/apxs2 --with-mysql-sock=/run/mysqld/mysqld.sock --enable-mbstring --enable-exif --enable-ftp --with-zip --enable-soap --with-mysqli --with-pdo-mysql --with-curl --with-openssl --with-zlib --with-bz2 --enable-gd --with-webp --with-jpeg --with-xpm --with-freetype --with-tidy --with-xsl --with-sodium --enable-shmop --with-mm --with-pspell --with-pear
The content of php.ini is
zend_extension=opcache.so
max_execution_time=2
memory_limit=2048M
display_errors=on
error_reporting=E_ALL
Test script:
---------------
<?php
register_shutdown_function ('shutdown');
file_put_contents ('/home/me/data/test.txt', "main 1 \n", FILE_APPEND | LOCK_EX);
file_put_contents ('/home/me/data/test.txt', "main 2 \n", FILE_APPEND | LOCK_EX);
a: goto a;
function shutdown () {
$error = error_get_last();
if ( ! is_null($error) ) {
file_put_contents ('/home/me/data/test.txt', "shutdown 1 \n", FILE_APPEND | LOCK_EX);
file_put_contents ('/home/me/data/test.txt', "shutdown 2 \n", FILE_APPEND | LOCK_EX);
}
exit;
}
?>
Expected result:
----------------
main 1
main 2
shutdown 1
shutdown 2
Actual result:
--------------
main 1
main 2
shutdown 1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
The fact that the shutdown function in my test script was activated by a max-execution-time exception is not relevant. Below test script has the same problem. <?php register_shutdown_function ('shutdown'); file_put_contents ('/tmp/test.txt', '1', FILE_APPEND | LOCK_EX); file_put_contents ('/tmp/test.txt', '2', FILE_APPEND | LOCK_EX); function shutdown () { file_put_contents ('/tmp/test.txt', '3', FILE_APPEND | LOCK_EX); file_put_contents ('/tmp/test.txt', '4', FILE_APPEND | LOCK_EX); } ?>