handle signals

This commit is contained in:
Julien Danjou 2007-12-27 16:03:21 +01:00
parent 77bb659563
commit 029f73ddfc
1 changed files with 12 additions and 0 deletions

View File

@ -29,6 +29,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <fcntl.h>
#include <signal.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
@ -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)
{