php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: thewitness at cacti dot net
New email:
PHP Version: OS:

 

 [2021-10-08 16:24 UTC] 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?

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 08 20:03:34 2021 UTC