Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.0

Bug #19577 SIG_BLOCK, SIG_UNBLOCK and SIG_SETMASK are treated as signal constants
Submitted: 2012-08-23 00:13 UTC
From: joris Assigned: kvz
Status: Closed Package: System_Daemon (version 1.0.0)
PHP Version: 5.3.3 OS: Debian (Squeeze)
Roadmaps: (Not assigned)    
Subscription  


 [2012-08-23 00:13 UTC] joris (Joris van de Sande)
Description: ------------ The SIG_BLOCK, SIG_UNBLOCK and SIG_SETMASK are treated as signal constants. However these constants are used in the pcntl_sigprocmask (http://php.net/manual/en/function.pcntl-sigprocmask.php) for another purpose. This leads to some unexpected behaviour, because these constants share there values with the signal constants. This becomes a real problem, because a custom callback for a SIGHUP signal is overwritten when starting the daemon (calling start()). This makes it impossible for me to create a custom restart callback. The solution is to remove the following lines from the $_sigHandlers array (line 422): 'SIG_BLOCK' => array('System_Daemon', 'defaultSigHandler'), 'SIG_UNBLOCK' => array('System_Daemon', 'defaultSigHandler'), 'SIG_SETMASK' => array('System_Daemon', 'defaultSigHandler'), Test script: --------------- // set signal handler for SIGHUP signal System_Daemon::setSigHandler(SIGHUP, function($signo) { System_Daemon::debug('Restarting!'); System_Daemon::restart(); }); // start daemon System_Daemon::start(); // Now my custom callback is suddenly overwritten with the default callback Expected result: ---------------- When sending a HUP signal to the process my custom SIGHUP signal handler should be executed. Actual result: -------------- The default signal handler in System_Daemon is called, because the code in System_Daemon::start() causes my custom signal handler to be overwritten.

Comments

 [2012-08-23 00:16 UTC] joris (Joris van de Sande)
To make things more clear: The value of the SIGHUP constant in my php version is 1 which is the same value as SIG_UNBLOCK. But like I already wrote in the description I think the SIG_ constants do not belong in the _sigHandlers array, because they are not signal constants.
 [2012-08-23 18:34 UTC] kvz (Kevin van Zonneveld)
-Status: Open +Status: Closed -Assigned To: +Assigned To: kvz
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Thanks for reporting this. Fixed in https://github.com/kvz/system_daemon/commit/754e5506847bb85b0e0a6f9f8b4f2bca fe5bb572