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

Request #16144 Add ability to notify script of signals
Submitted: 2009-04-23 00:46 UTC
From: garrettmoon Assigned: kvz
Status: Bogus Package: System_Daemon (version 0.7.0)
PHP Version: 5.2.9 OS: Debian
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 : 50 - 44 = ?

 
 [2009-04-23 00:46 UTC] garrettmoon (Garrett Moon)
Description: ------------ It would be nice if there was a callback function or something like it to notify the script that it's going to die so it can do cleanup of its own. I believe this could be currently achieved by overloading _die(), but a callback seems cleaner. Maybe I'm just missing something?

Comments

 [2009-04-23 00:56 UTC] kvz (Kevin van Zonneveld)
I think what you want is defining your own signal handler. If the daemon gets the POSIX signal to die, then your function will be executed. Is this indeed what you need?
 [2009-04-23 01:06 UTC] garrettmoon (Garrett Moon)
Well, if I define the signal handlers before I call System_Daemon, mine get eaten up. Also, I think it would be beneficial to allow the daemon to handle the signals as it cleans up the PID file, etc. FYI, I really appreciate this library and your work on it!
 [2009-04-23 01:22 UTC] kvz (Kevin van Zonneveld)
Sorry I don't understand. They get eaten up? Maybe you can show me (use a link to pastebin.org or sth) how exactly you are using the signal handlers. And of course you can always finally make a call to System_Daemon::stop() in your signal handler, which cleans up the pid file.
 [2009-04-23 02:08 UTC] garrettmoon (Garrett Moon)
calling stop() should work just fine. By eaten I meant that because I installed signal handlers before System_Daemon did, my signal handlers were replaced by system_daemons. Thanks!
 [2009-04-23 12:41 UTC] kvz (Kevin van Zonneveld)
They should not be overridden if you use the built-in setSigHandler method: /** * Overrule or add signal handlers. * * @param string $signal Signal constant (e.g. SIGHUP) * @param mixed $handler Which handler to call on signal * * @return boolean * @see $_sigHandlers */ static public function setSigHandler($signal, $handler) This wil reroute incomming signals to your own $handler which can be a function in your script. From that function you can do what you want & then call stop(); So you're good now?
 [2009-04-23 22:05 UTC] garrettmoon (Garrett Moon)
I'm good, thank you!
 [2009-04-25 15:14 UTC] kvz (Kevin van Zonneveld)
-Status: Open +Status: Bogus
Ok then I'm closing this issue
 [2012-07-17 16:13 UTC] kvz (Kevin van Zonneveld)
-Assigned To: +Assigned To: kvz