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
View Add Comment Developer Edit
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:
38 - 29 = ?
Subscribe to this entry?

 
 [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)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC