php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72409 pcntl_signal function could return previous value of the signal handler
Submitted: 2016-06-15 09:06 UTC Modified: -
From: jan dot kahoun at heureka dot cz Assigned:
Status: Closed Package: PCNTL related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jan dot kahoun at heureka dot cz
New email:
PHP Version: OS:

 

 [2016-06-15 09:06 UTC] jan dot kahoun at heureka dot cz
Description:
------------
This function could be similar to C signal() function (http://www.gnu.org/software/libc/manual/html_node/Basic-Signal-Handling.html) and return the previous value of the signal handler for passed signal, or false on error. This can be helpfull when you need to restore previous handler

Test script:
---------------
<?php
declare(ticks = 1);

function sig_handler($signo)
{

     switch ($signo) {
         case SIGTERM:
             exit;
             break;
         default:
     }

}

// this will return previous handler for SIGTERM signal
$previous_handler = pcntl_signal(SIGTERM, "sig_handler");

// restore previous handler
$previous_handler = pcntl_signal(SIGTERM, $previous_handler);

Expected result:
----------------
function pcntl_signal() returns previous value of the signal handler for passed signal on success or FALSE on failure

Actual result:
--------------
function pcntl_signal() returns TRUE on success or FALSE on failure

Patches

return-previous-handler (last revision 2016-06-18 08:20 UTC by dave at mudsite dot com)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-18 08:16 UTC] dave at mudsite dot com
I created a patch that will return true when there isn't a user defined handler, but would return the value set as the handler.  It would be string, if string, or array if array.
 [2016-07-06 19:09 UTC] trowski@php.net
Automatic comment on behalf of dave@mudsite.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=217dcbcd911ad0552a4435fe979c069a5ddaef9f
Log: Fix #72409 - return previous handler
 [2016-07-06 19:09 UTC] trowski@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:30 UTC] davey@php.net
Automatic comment on behalf of dave@mudsite.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=217dcbcd911ad0552a4435fe979c069a5ddaef9f
Log: Fix #72409 - return previous handler
 [2016-10-17 10:11 UTC] bwoebi@php.net
Automatic comment on behalf of dave@mudsite.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=217dcbcd911ad0552a4435fe979c069a5ddaef9f
Log: Fix #72409 - return previous handler
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Mar 31 07:01:29 2025 UTC