diff options
author | fluxgen <fluxgen> | 2002-08-14 00:01:10 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-08-14 00:01:10 (GMT) |
commit | fdd8313050bb2f36a204e9104dc78c9c268e4d52 (patch) | |
tree | 9721ec2562f3939c003ce3fe61d53fedc0410a26 /src | |
parent | 76a1c5c161de5142ae468575dcba537f02d31686 (diff) | |
download | fluxbox-fdd8313050bb2f36a204e9104dc78c9c268e4d52.zip fluxbox-fdd8313050bb2f36a204e9104dc78c9c268e4d52.tar.bz2 |
changed signalhandling to FbTk SignalHandler
Diffstat (limited to 'src')
-rw-r--r-- | src/fluxbox.cc | 79 | ||||
-rw-r--r-- | 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 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: fluxbox.cc,v 1.66 2002/08/13 21:19:00 fluxgen Exp $ | 25 | // $Id: fluxbox.cc,v 1.67 2002/08/14 00:01:10 fluxgen Exp $ |
26 | 26 | ||
27 | #include "fluxbox.hh" | 27 | #include "fluxbox.hh" |
28 | 28 | ||
@@ -111,12 +111,15 @@ | |||
111 | # include <libgen.h> | 111 | # include <libgen.h> |
112 | #endif // HAVE_LIBGEN_H | 112 | #endif // HAVE_LIBGEN_H |
113 | 113 | ||
114 | #include <sys/wait.h> | ||
115 | |||
114 | #include <iostream> | 116 | #include <iostream> |
115 | #include <string> | 117 | #include <string> |
116 | #include <memory> | 118 | #include <memory> |
117 | #include <algorithm> | 119 | #include <algorithm> |
118 | 120 | ||
119 | using namespace std; | 121 | using namespace std; |
122 | using namespace FbTk; | ||
120 | 123 | ||
121 | #ifndef HAVE_BASENAME | 124 | #ifndef HAVE_BASENAME |
122 | namespace { | 125 | namespace { |
@@ -313,6 +316,18 @@ key(0) | |||
313 | cerr<<"Fatal! There can only one instance of fluxbox class."<<endl; | 316 | cerr<<"Fatal! There can only one instance of fluxbox class."<<endl; |
314 | abort(); | 317 | abort(); |
315 | } | 318 | } |
319 | |||
320 | //setup signals | ||
321 | SignalHandler *sigh = SignalHandler::instance(); | ||
322 | |||
323 | sigh->registerHandler(SIGSEGV, this); | ||
324 | sigh->registerHandler(SIGFPE, this); | ||
325 | sigh->registerHandler(SIGTERM, this); | ||
326 | sigh->registerHandler(SIGINT, this); | ||
327 | sigh->registerHandler(SIGCHLD, this); | ||
328 | sigh->registerHandler(SIGHUP, this); | ||
329 | sigh->registerHandler(SIGUSR1, this); | ||
330 | sigh->registerHandler(SIGUSR2, this); | ||
316 | 331 | ||
317 | //singleton pointer | 332 | //singleton pointer |
318 | singleton = this; | 333 | singleton = this; |
@@ -324,7 +339,7 @@ key(0) | |||
324 | if (! XSupportsLocale()) | 339 | if (! XSupportsLocale()) |
325 | fprintf(stderr, "X server does not support locale\n"); | 340 | fprintf(stderr, "X server does not support locale\n"); |
326 | 341 | ||
327 | if (XSetLocaleModifiers("") == NULL) | 342 | if (XSetLocaleModifiers("") == 0) |
328 | fprintf(stderr, "cannot set locale modifiers\n"); | 343 | fprintf(stderr, "cannot set locale modifiers\n"); |
329 | 344 | ||
330 | // Set default values to member variables | 345 | // Set default values to member variables |
@@ -1562,30 +1577,56 @@ bool Fluxbox::checkNETWMAtoms(XClientMessageEvent &ce) { | |||
1562 | } | 1577 | } |
1563 | #endif //!NEWWMSPEC | 1578 | #endif //!NEWWMSPEC |
1564 | 1579 | ||
1565 | Bool Fluxbox::handleSignal(int sig) { | 1580 | void Fluxbox::handleSignal(int sig) { |
1581 | I18n *i18n = I18n::instance(); | ||
1582 | static int re_enter = 0; | ||
1583 | |||
1566 | switch (sig) { | 1584 | switch (sig) { |
1567 | case SIGHUP: | 1585 | case SIGCHLD: // we don't want the child process to kill us |
1568 | load_rc(); | 1586 | waitpid(-1, 0, WNOHANG | WUNTRACED); |
1569 | break; | 1587 | break; |
1570 | 1588 | case SIGHUP: | |
1571 | case SIGUSR1: | 1589 | load_rc(); |
1572 | reload_rc(); | ||
1573 | break; | 1590 | break; |
1574 | 1591 | case SIGUSR1: | |
1575 | case SIGUSR2: | 1592 | reload_rc(); |
1576 | rereadMenu(); | 1593 | break; |
1594 | case SIGUSR2: | ||
1595 | rereadMenu(); | ||
1577 | break; | 1596 | break; |
1597 | case SIGSEGV: | ||
1598 | case SIGFPE: | ||
1599 | case SIGINT: | ||
1600 | case SIGTERM: | ||
1601 | shutdown(); | ||
1602 | break; | ||
1603 | default: | ||
1604 | fprintf(stderr, | ||
1605 | i18n->getMessage( | ||
1606 | FBNLS::BaseDisplaySet, FBNLS::BaseDisplaySignalCaught, | ||
1607 | "%s: signal %d caught\n"), | ||
1608 | getApplicationName(), sig); | ||
1609 | |||
1610 | if (! isStartup() && ! re_enter) { | ||
1611 | re_enter = 1; | ||
1612 | fprintf(stderr, | ||
1613 | i18n->getMessage( | ||
1614 | FBNLS::BaseDisplaySet, FBNLS::BaseDisplayShuttingDown, | ||
1615 | "shutting down\n")); | ||
1616 | shutdown(); | ||
1617 | } | ||
1578 | 1618 | ||
1579 | case SIGSEGV: | 1619 | |
1580 | case SIGFPE: | 1620 | fprintf(stderr, |
1581 | case SIGINT: | 1621 | i18n->getMessage( |
1582 | case SIGTERM: | 1622 | FBNLS::BaseDisplaySet, FBNLS::BaseDisplayAborting, |
1583 | shutdown(); | 1623 | "aborting... dumping core\n")); |
1584 | default: | 1624 | abort(); |
1585 | return False; | 1625 | break; |
1586 | } | 1626 | } |
1587 | 1627 | ||
1588 | return True; | 1628 | |
1629 | |||
1589 | } | 1630 | } |
1590 | 1631 | ||
1591 | 1632 | ||
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 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: fluxbox.hh,v 1.24 2002/08/13 21:18:17 fluxgen Exp $ | 25 | // $Id: fluxbox.hh,v 1.25 2002/08/14 00:00:16 fluxgen Exp $ |
26 | 26 | ||
27 | #ifndef FLUXBOX_HH | 27 | #ifndef FLUXBOX_HH |
28 | #define FLUXBOX_HH | 28 | #define FLUXBOX_HH |
@@ -40,12 +40,12 @@ | |||
40 | #include "Slit.hh" | 40 | #include "Slit.hh" |
41 | #endif // SLIT | 41 | #endif // SLIT |
42 | 42 | ||
43 | #include "SignalHandler.hh" | ||
44 | |||
43 | #include <X11/Xlib.h> | 45 | #include <X11/Xlib.h> |
44 | #include <X11/Xresource.h> | 46 | #include <X11/Xresource.h> |
45 | 47 | ||
46 | #ifdef HAVE_STDIO_H | 48 | #include <cstdio> |
47 | # include <stdio.h> | ||
48 | #endif // HAVE_STDIO_H | ||
49 | 49 | ||
50 | #ifdef TIME_WITH_SYS_TIME | 50 | #ifdef TIME_WITH_SYS_TIME |
51 | #include <sys/time.h> | 51 | #include <sys/time.h> |
@@ -67,7 +67,7 @@ | |||
67 | main class for the window manager. | 67 | main class for the window manager. |
68 | singleton type | 68 | singleton type |
69 | */ | 69 | */ |
70 | class Fluxbox : public BaseDisplay, public TimeoutHandler { | 70 | class Fluxbox : public BaseDisplay, public TimeoutHandler, public FbTk::SignalHandler::EventHandler { |
71 | public: | 71 | public: |
72 | Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0); | 72 | Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0); |
73 | virtual ~Fluxbox(); | 73 | virtual ~Fluxbox(); |
@@ -147,8 +147,9 @@ public: | |||
147 | void reconfigureTabs(); | 147 | void reconfigureTabs(); |
148 | void rereadMenu(); | 148 | void rereadMenu(); |
149 | void checkMenu(); | 149 | void checkMenu(); |
150 | 150 | ||
151 | virtual Bool handleSignal(int); | 151 | /// handle any signal sent to the application |
152 | void handleSignal(int signum); | ||
152 | 153 | ||
153 | virtual void timeout(); | 154 | virtual void timeout(); |
154 | 155 | ||