php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77335 PHP is preventing SIGALRM from specifying SA_RESTART
Submitted: 2018-12-21 18:42 UTC Modified: 2019-10-02 11:32 UTC
Votes:3
Avg. Score:3.3 ± 0.5
Reproduced:0 of 0 (0.0%)
From: v-yitam at microsoft dot com Assigned: nikic (profile)
Status: Closed Package: PCNTL related
PHP Version: Irrelevant OS: CentOS 7 or Ubuntu 18.04
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
20 - 15 = ?
Subscribe to this entry?

 
 [2018-12-21 18:42 UTC] v-yitam at microsoft dot com
Description:
------------
When signo is SIGALRM, it never gets to the else clause, see this line here,

https://github.com/php/php-src/blob/master/ext/pcntl/php_signal.c#L44

Note that even though $restart_syscalls is true by default, it does not help or do anything:

bool pcntl_signal ( int $signo , callable|int $handler [, bool $restart_syscalls = TRUE ] )

http://php.net/manual/en/function.pcntl-signal.php

For your reference, please check https://www.postgresql.org/message-id/E1UnwKf-0002LU-W4@gemulon.postgresql.org 

Test script:
---------------
You can find the repro for pdo_sqlsrv in https://github.com/Microsoft/msphpsql/issues/885

<?php

$pdo = new PDO('sqlsrv:Server=;Database=', '', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

function handleAlarm() {
        echo "Received SIGALRM!";
        pcntl_alarm(2);
}

pcntl_async_signals(true);
pcntl_signal( SIGALRM, 'handleAlarm');
pcntl_alarm(2);

while(1) {
        $testresult = $pdo->query("SELECT * FROM users;");
        foreach($testresult as $r) {}
        echo '.';
}

Expected result:
----------------
No exception thrown

Actual result:
--------------
Exception thrown

Patches

php_signal_diff.log (last revision 2018-12-21 18:43 UTC by v-yitam at microsoft dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-02 11:32 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2019-10-02 11:32 UTC] nikic@php.net
This is fixed by https://github.com/php/php-src/commit/e98e1f92c98b7c8910c55835d8f67d0d9230cc8b, though it will be necessary to specify $restart_syscalls explicitly:

pcntl_signal(SIGALRM, 'handleAlarm', true);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 09:01:27 2024 UTC