aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc79
1 files changed, 60 insertions, 19 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
119using namespace std; 121using namespace std;
122using namespace FbTk;
120 123
121#ifndef HAVE_BASENAME 124#ifndef HAVE_BASENAME
122namespace { 125namespace {
@@ -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
1565Bool Fluxbox::handleSignal(int sig) { 1580void 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