|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81515 PDO-MySQL is Blocking Signal Prop
Submitted: 2021-10-08 16:24 UTC Modified: -
From: thewitness at cacti dot net Assigned:
Status: Open Package: PDO MySQL
PHP Version: Irrelevant OS: x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: thewitness at cacti dot net
New email:
PHP Version: OS:


 [2021-10-08 16:24 UTC] thewitness at cacti dot net
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:
if (function_exists('pcntl_async_signals')) {
} 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";
        /* 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?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-12-28 18:24 UTC] molsavsky1 at gmail dot com
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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 05:01:32 2024 UTC