From fdd8313050bb2f36a204e9104dc78c9c268e4d52 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 14 Aug 2002 00:01:10 +0000 Subject: changed signalhandling to FbTk SignalHandler --- src/fluxbox.cc | 79 ++++++++++++++++++++++++++++++++++++++++++++-------------- src/fluxbox.hh | 15 +++++------ 2 files changed, 68 insertions(+), 26 deletions(-) diff --git a/src/fluxbox.cc b/src/fluxbox.cc index c45c340..e61ccef 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.66 2002/08/13 21:19:00 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.67 2002/08/14 00:01:10 fluxgen Exp $ #include "fluxbox.hh" @@ -111,12 +111,15 @@ # include #endif // HAVE_LIBGEN_H +#include + #include #include #include #include using namespace std; +using namespace FbTk; #ifndef HAVE_BASENAME namespace { @@ -313,6 +316,18 @@ key(0) cerr<<"Fatal! There can only one instance of fluxbox class."<registerHandler(SIGSEGV, this); + sigh->registerHandler(SIGFPE, this); + sigh->registerHandler(SIGTERM, this); + sigh->registerHandler(SIGINT, this); + sigh->registerHandler(SIGCHLD, this); + sigh->registerHandler(SIGHUP, this); + sigh->registerHandler(SIGUSR1, this); + sigh->registerHandler(SIGUSR2, this); //singleton pointer singleton = this; @@ -324,7 +339,7 @@ key(0) if (! XSupportsLocale()) fprintf(stderr, "X server does not support locale\n"); - if (XSetLocaleModifiers("") == NULL) + if (XSetLocaleModifiers("") == 0) fprintf(stderr, "cannot set locale modifiers\n"); // Set default values to member variables @@ -1562,30 +1577,56 @@ bool Fluxbox::checkNETWMAtoms(XClientMessageEvent &ce) { } #endif //!NEWWMSPEC -Bool Fluxbox::handleSignal(int sig) { +void Fluxbox::handleSignal(int sig) { + I18n *i18n = I18n::instance(); + static int re_enter = 0; + switch (sig) { - case SIGHUP: - load_rc(); + case SIGCHLD: // we don't want the child process to kill us + waitpid(-1, 0, WNOHANG | WUNTRACED); break; - - case SIGUSR1: - reload_rc(); + case SIGHUP: + load_rc(); break; - - case SIGUSR2: - rereadMenu(); + case SIGUSR1: + reload_rc(); + break; + case SIGUSR2: + rereadMenu(); break; + case SIGSEGV: + case SIGFPE: + case SIGINT: + case SIGTERM: + shutdown(); + break; + default: + fprintf(stderr, + i18n->getMessage( + FBNLS::BaseDisplaySet, FBNLS::BaseDisplaySignalCaught, + "%s: signal %d caught\n"), + getApplicationName(), sig); + + if (! isStartup() && ! re_enter) { + re_enter = 1; + fprintf(stderr, + i18n->getMessage( + FBNLS::BaseDisplaySet, FBNLS::BaseDisplayShuttingDown, + "shutting down\n")); + shutdown(); + } - case SIGSEGV: - case SIGFPE: - case SIGINT: - case SIGTERM: - shutdown(); - default: - return False; + + fprintf(stderr, + i18n->getMessage( + FBNLS::BaseDisplaySet, FBNLS::BaseDisplayAborting, + "aborting... dumping core\n")); + abort(); + break; } - return True; + + } diff --git a/src/fluxbox.hh b/src/fluxbox.hh index a8de98c..b6b5beb 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.hh,v 1.24 2002/08/13 21:18:17 fluxgen Exp $ +// $Id: fluxbox.hh,v 1.25 2002/08/14 00:00:16 fluxgen Exp $ #ifndef FLUXBOX_HH #define FLUXBOX_HH @@ -40,12 +40,12 @@ #include "Slit.hh" #endif // SLIT +#include "SignalHandler.hh" + #include #include -#ifdef HAVE_STDIO_H -# include -#endif // HAVE_STDIO_H +#include #ifdef TIME_WITH_SYS_TIME #include @@ -67,7 +67,7 @@ main class for the window manager. singleton type */ -class Fluxbox : public BaseDisplay, public TimeoutHandler { +class Fluxbox : public BaseDisplay, public TimeoutHandler, public FbTk::SignalHandler::EventHandler { public: Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0); virtual ~Fluxbox(); @@ -147,8 +147,9 @@ public: void reconfigureTabs(); void rereadMenu(); void checkMenu(); - - virtual Bool handleSignal(int); + + /// handle any signal sent to the application + void handleSignal(int signum); virtual void timeout(); -- cgit v0.11.2