changed signalhandling to FbTk SignalHandler
This commit is contained in:
parent
76a1c5c161
commit
fdd8313050
2 changed files with 68 additions and 26 deletions
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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"
|
#include "fluxbox.hh"
|
||||||
|
|
||||||
|
@ -111,12 +111,15 @@
|
||||||
# include <libgen.h>
|
# include <libgen.h>
|
||||||
#endif // HAVE_LIBGEN_H
|
#endif // HAVE_LIBGEN_H
|
||||||
|
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace FbTk;
|
||||||
|
|
||||||
#ifndef HAVE_BASENAME
|
#ifndef HAVE_BASENAME
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -314,6 +317,18 @@ key(0)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//setup signals
|
||||||
|
SignalHandler *sigh = SignalHandler::instance();
|
||||||
|
|
||||||
|
sigh->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 pointer
|
||||||
singleton = this;
|
singleton = this;
|
||||||
BaseDisplay::GrabGuard gg(*this);
|
BaseDisplay::GrabGuard gg(*this);
|
||||||
|
@ -324,7 +339,7 @@ key(0)
|
||||||
if (! XSupportsLocale())
|
if (! XSupportsLocale())
|
||||||
fprintf(stderr, "X server does not support locale\n");
|
fprintf(stderr, "X server does not support locale\n");
|
||||||
|
|
||||||
if (XSetLocaleModifiers("") == NULL)
|
if (XSetLocaleModifiers("") == 0)
|
||||||
fprintf(stderr, "cannot set locale modifiers\n");
|
fprintf(stderr, "cannot set locale modifiers\n");
|
||||||
|
|
||||||
// Set default values to member variables
|
// Set default values to member variables
|
||||||
|
@ -1562,30 +1577,56 @@ bool Fluxbox::checkNETWMAtoms(XClientMessageEvent &ce) {
|
||||||
}
|
}
|
||||||
#endif //!NEWWMSPEC
|
#endif //!NEWWMSPEC
|
||||||
|
|
||||||
Bool Fluxbox::handleSignal(int sig) {
|
void Fluxbox::handleSignal(int sig) {
|
||||||
|
I18n *i18n = I18n::instance();
|
||||||
|
static int re_enter = 0;
|
||||||
|
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
|
case SIGCHLD: // we don't want the child process to kill us
|
||||||
|
waitpid(-1, 0, WNOHANG | WUNTRACED);
|
||||||
|
break;
|
||||||
case SIGHUP:
|
case SIGHUP:
|
||||||
load_rc();
|
load_rc();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
reload_rc();
|
reload_rc();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGUSR2:
|
case SIGUSR2:
|
||||||
rereadMenu();
|
rereadMenu();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGSEGV:
|
case SIGSEGV:
|
||||||
case SIGFPE:
|
case SIGFPE:
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
shutdown();
|
shutdown();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return False;
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
return True;
|
|
||||||
|
fprintf(stderr,
|
||||||
|
i18n->getMessage(
|
||||||
|
FBNLS::BaseDisplaySet, FBNLS::BaseDisplayAborting,
|
||||||
|
"aborting... dumping core\n"));
|
||||||
|
abort();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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
|
#ifndef FLUXBOX_HH
|
||||||
#define FLUXBOX_HH
|
#define FLUXBOX_HH
|
||||||
|
@ -40,12 +40,12 @@
|
||||||
#include "Slit.hh"
|
#include "Slit.hh"
|
||||||
#endif // SLIT
|
#endif // SLIT
|
||||||
|
|
||||||
|
#include "SignalHandler.hh"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xresource.h>
|
#include <X11/Xresource.h>
|
||||||
|
|
||||||
#ifdef HAVE_STDIO_H
|
#include <cstdio>
|
||||||
# include <stdio.h>
|
|
||||||
#endif // HAVE_STDIO_H
|
|
||||||
|
|
||||||
#ifdef TIME_WITH_SYS_TIME
|
#ifdef TIME_WITH_SYS_TIME
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
main class for the window manager.
|
main class for the window manager.
|
||||||
singleton type
|
singleton type
|
||||||
*/
|
*/
|
||||||
class Fluxbox : public BaseDisplay, public TimeoutHandler {
|
class Fluxbox : public BaseDisplay, public TimeoutHandler, public FbTk::SignalHandler::EventHandler {
|
||||||
public:
|
public:
|
||||||
Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0);
|
Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0);
|
||||||
virtual ~Fluxbox();
|
virtual ~Fluxbox();
|
||||||
|
@ -148,7 +148,8 @@ public:
|
||||||
void rereadMenu();
|
void rereadMenu();
|
||||||
void checkMenu();
|
void checkMenu();
|
||||||
|
|
||||||
virtual Bool handleSignal(int);
|
/// handle any signal sent to the application
|
||||||
|
void handleSignal(int signum);
|
||||||
|
|
||||||
virtual void timeout();
|
virtual void timeout();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue