From 029f73ddfc1818b2d4e97067f88ab18ae7aaf429 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 27 Dec 2007 16:03:21 +0100 Subject: [PATCH] handle signals --- awesome.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/awesome.c b/awesome.c index 1ee98423..a57d1fe2 100644 --- a/awesome.c +++ b/awesome.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -243,6 +244,12 @@ uicb_quit(int screen __attribute__ ((unused)), char *arg __attribute__ ((unused) running = False; } +static void +exit_on_signal(int sig __attribute__ ((unused))) +{ + running = False; +} + /* There's no way to check accesses to destroyed windows, thus those cases are * ignored (especially on UnmapNotify's). Other types of errors call Xlibs * default error handler, which may call exit. @@ -398,6 +405,11 @@ main(int argc, char *argv[]) perror("error binding UNIX domain socket"); } + /* register function for signals */ + signal(SIGINT, &exit_on_signal); + signal(SIGTERM, &exit_on_signal); + signal(SIGHUP, &exit_on_signal); + /* main event loop, also reads status text from socket */ while(running) {