|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-12-28 18:24 UTC] molsavsky1 at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 13:00:01 2025 UTC |
Description: ------------ It appears that if you install any signal handler for PHP, signal propagation to the PDO MySQL library is blocked. So, as long as I have say a long running query, the PHP script will not respond to the signal. However, if I don't install a signal handler, the script will terminate as expected. It's pretty strait forward to test. Test script: --------------- <?php if (function_exists('pcntl_async_signals')) { pcntl_async_signals(true); } else { declare(ticks = 1); } /* install signal handlers for UNIX only */ if (function_exists('pcntl_signal')) { pcntl_signal(SIGTERM, 'etl_sig_handler', true); pcntl_signal(SIGINT, 'etl_sig_handler', true); } // Using Cacti DB API... $data = db_fetch_cell('SELECT SLEEP(50000)'); function etl_sig_handler($signo) { switch ($signo) { case SIGTERM: case SIGINT: echo "Boo!\n"; exit; break; default: /* ignore all other signals */ } } Expected result: ---------------- These signals should not be blocked. If they are not blocked, the query should be killed, but not necessarily the connection. At least if the signal handlers were not blocked, we could kill either the connection or the query out of band. Actual result: -------------- Currently, the PDO calls are blocked/masked. I have read that this may be a limitation of the MySQL/MariaDB client library, but then why does CTRL-C work if there is no signal handler installed?