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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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

Pull Requests

History

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.

https://github.com/php/php-src/issues/7846
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC