Bug #81515 [Com]: PDO-MySQL is Blocking Signal Prop

From: Date: Tue, 28 Dec 2021 18:24:34 +0000
Subject: Bug #81515 [Com]: PDO-MySQL is Blocking Signal Prop
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238612@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81515&edit=1 ID: 81515 Comment by: molsavsky1 at gmail dot com Reported by: thewitness at cacti dot net Summary: PDO-MySQL is Blocking Signal Prop Status: Open Type: Bug Package: PDO MySQL Operating System: x86_64 PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Similar issue occurs with CURL (and supposedly other native C libraries) as well. If it's a hard to overcome technical limitation, it should be at least documented. https://github.com/php/php-src/issues/7846 Previous Comments: ------------------------------------------------------------------------ [2021-10-08 16:24:34] thewitness at cacti dot net 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? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81515&edit=1

« previous php.bugs (#238612) next »