aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.hh
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2014-02-18 18:34:35 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2014-02-18 18:34:35 (GMT)
commit43bdf499d56c09a520dc3bc03438dee4092d3d58 (patch)
treefc08fe113eb7c577eb402bf9ffebd8038d4f90da /src/fluxbox.hh
parent3696562aa87c7e68cb8b00b85f0e8d5cf2d199bf (diff)
downloadfluxbox-43bdf499d56c09a520dc3bc03438dee4092d3d58.zip
fluxbox-43bdf499d56c09a520dc3bc03438dee4092d3d58.tar.bz2
Fix race condition on shutdown
This commit fixes primarily a race condition that occurs when xinit(1) shuts down: by not acting properly fluxbox gets caught in an infinite loop. It caused bug #1100. xinit(1) sends a SIGHUP signal to all processes. fluxbox tries to shutdown itself properly by shutting down workspaces and screens. While doing that, the Xserver might be gone already. Additionally, fluxbox used to restart() itself on SIGHUP, which is clearly not the right thing to do when xinit(1) is about to end the session. So, fluxbox does this: * handling SIGHUP now shuts down fluxbox without clearing workspaces and screens. * A 2 second alarm() is triggered in Fluxbox::shutdown() as a last resort * XSetIOErrorHandler() is used to recognize the disconnect from the xserver. * SIGUSR1 is for restarting fluxbox, SIGUSR2 for reloading the config * FbTk/SignalHandler.cc/hh is gone; this unused abstraction served currently no real purpose. Signal handling is now done in main.cc * Unrelated to the issue itself src/main.cc was trimmed down quite a bit and the code (responsible for handling the command line interface) was moved to src/cli*
Diffstat (limited to 'src/fluxbox.hh')
-rw-r--r--src/fluxbox.hh15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index f83934a..f6a8f26 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -28,23 +28,22 @@
28#include "FbTk/App.hh" 28#include "FbTk/App.hh"
29#include "FbTk/Resource.hh" 29#include "FbTk/Resource.hh"
30#include "FbTk/Timer.hh" 30#include "FbTk/Timer.hh"
31#include "FbTk/SignalHandler.hh"
32#include "FbTk/Signal.hh" 31#include "FbTk/Signal.hh"
33 32
34#include "AttentionNoticeHandler.hh" 33#include "AttentionNoticeHandler.hh"
35 34
36#include <X11/Xresource.h> 35#include <X11/Xresource.h>
37 36
37#ifdef HAVE_CONFIG_H
38#include "config.h"
39#endif // HAVE_CONFIG_H
40
38#ifdef HAVE_CSTDIO 41#ifdef HAVE_CSTDIO
39 #include <cstdio> 42 #include <cstdio>
40#else 43#else
41 #include <stdio.h> 44 #include <stdio.h>
42#endif 45#endif
43 46
44#ifdef HAVE_CONFIG_H
45#include "config.h"
46#endif // HAVE_CONFIG_H
47
48#ifdef TIME_WITH_SYS_TIME 47#ifdef TIME_WITH_SYS_TIME
49#include <sys/time.h> 48#include <sys/time.h>
50#include <time.h> 49#include <time.h>
@@ -74,7 +73,6 @@ class FbAtoms;
74 singleton type 73 singleton type
75*/ 74*/
76class Fluxbox : public FbTk::App, 75class Fluxbox : public FbTk::App,
77 public FbTk::SignalEventHandler,
78 private FbTk::SignalTracker { 76 private FbTk::SignalTracker {
79public: 77public:
80 Fluxbox(int argc, char **argv, 78 Fluxbox(int argc, char **argv,
@@ -137,7 +135,7 @@ public:
137 void maskWindowEvents(Window w, FluxboxWindow *bw) 135 void maskWindowEvents(Window w, FluxboxWindow *bw)
138 { m_masked = w; m_masked_window = bw; } 136 { m_masked = w; m_masked_window = bw; }
139 137
140 void shutdown(); 138 void shutdown(int x_wants_down = 0);
141 void load_rc(BScreen &scr); 139 void load_rc(BScreen &scr);
142 void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } 140 void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); }
143 void saveWindowSearch(Window win, WinClient *winclient); 141 void saveWindowSearch(Window win, WinClient *winclient);
@@ -152,8 +150,6 @@ public:
152 void restart(const char *command = 0); 150 void restart(const char *command = 0);
153 void reconfigure(); 151 void reconfigure();
154 152
155 /// handle any system signal sent to the application
156 void handleSignal(int signum);
157 /// todo, remove this. just temporary 153 /// todo, remove this. just temporary
158 void updateFrameExtents(FluxboxWindow &win); 154 void updateFrameExtents(FluxboxWindow &win);
159 155
@@ -168,6 +164,7 @@ public:
168 164
169 bool isStartup() const { return m_starting; } 165 bool isStartup() const { return m_starting; }
170 bool isRestarting() const { return m_restarting; } 166 bool isRestarting() const { return m_restarting; }
167 bool isShuttingDown() const { return m_shutdown; }
171 168
172 const std::string &getRestartArgument() const { return m_restart_argument; } 169 const std::string &getRestartArgument() const { return m_restart_argument; }
173 170