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

Bug #17224 Sig handler causes error
Submitted: 2010-03-15 13:16 UTC
From: garethm Assigned: kvz
Status: Closed Package: System_Daemon (version 0.10.1)
PHP Version: 5.2.10 OS: Centos
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


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 : 25 - 1 = ?

 
 [2010-03-15 13:16 UTC] garethm (Gareth McCumskey)
Description: ------------ When attempting to create a sig handler the script returns an error: Can only overrule on of these signal handlers: 'Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, 1, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array' In addition the signal does not get caught and the application is terminated even in the middle of processing. Test script: --------------- require_once("System/Daemon.php"); System_Daemon::setOption("appName", "name"); System_Daemon::setOption("appDescription", "Description"); System_Daemon::setOption("authorName", "Name"); System_Daemon::setOption("authorEmail", "mail@mail.com"); System_Daemon::setSigHandler(SIGKILL, array("System_Daemon","defaultSigHandler")); if (!System_Daemon::isInBackground() && !System_Daemon::isRunning()) { $init_path = System_Daemon::writeAutoRun(true); System_Daemon::start(); $sleep_time = 5; while (!System_Daemon::isDying()) { //Code to run per loop } System_Daemon::notice("Termination signal recieved, exiting"); } Expected result: ---------------- The sig handler gets set and when a termination signal for the running process is sent that the application manages shutting itself down instead of being killed outright Actual result: -------------- The error: Can only overrule on of these signal handlers: 'Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, 1, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array, Array' and no signal capturing

Comments

 [2010-03-15 22:30 UTC] austinb (Austin Bis)
There is no "SIGKILL" defined in the $_sigHandlers array. Actually seems to be a typo as the array key is defined as "SIGILL". static protected $_sigHandlers = array( SIGHUP => array('System_Daemon', 'defaultSigHandler'), SIGINT => array('System_Daemon', 'defaultSigHandler'), SIGQUIT => array('System_Daemon', 'defaultSigHandler'), SIGILL => array('System_Daemon', 'defaultSigHandler'), SIGTRAP => array('System_Daemon', 'defaultSigHandler'), .. ); The actual output of Array, Array is for incorrect joining of arrays on line 640 in Daemon.php. It should be join(', ', array_keys(self::$_sigHandlers)) to pull out the keys but then it will only show the defined value for SIGHUP, etc since there is no string version of the handlers defined to be displayed.
 [2010-03-16 00:23 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. The 'array array array array array array' issue has been resolved thanks to Austin Bis. That SIGKILL isn't in there is not a mistake though. You cannot assign a signal handler for SIGKILL (kill -9). We use SIGTERM instead. I've added a signals.php example to showcase how it could work. Here's the involved commit: http://github.com/kvz/system_daemon/commit/00ac3b14531df03ff193155bb99ecd dce3d588c3 I'll release this as 10.2 shortly. Thanks for diving into this guys!