summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2021-05-26 23:30:49 -0500
committerDevin J. Pohly <djpohly@gmail.com>2021-05-26 23:30:49 -0500
commitbd2f7fbb4082d947ec2738cd31d403e9f0c10f50 (patch)
tree81202e7848b51b38f1b64702a0bb002ad44503a5
parent823cefd2920085a0f74899fb679020005a1b6e0b (diff)
exit cleanly on INT/TERM
-rw-r--r--dwl.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/dwl.c b/dwl.c
index a38f452..a8e1dcd 100644
--- a/dwl.c
+++ b/dwl.c
@@ -259,6 +259,7 @@ static void pointerfocus(Client *c, struct wlr_surface *surface,
double sx, double sy, uint32_t time);
static void printstatus(void);
static void quit(const Arg *arg);
+static void quitsignal(int signo);
static void render(struct wlr_surface *surface, int sx, int sy, void *data);
static void renderclients(Monitor *m, struct timespec *now);
static void renderlayer(struct wl_list *layer_surfaces, struct timespec *now);
@@ -1579,6 +1580,12 @@ quit(const Arg *arg)
}
void
+quitsignal(int signo)
+{
+ quit(NULL);
+}
+
+void
render(struct wlr_surface *surface, int sx, int sy, void *data)
{
/* This function is called for every surface that needs to be rendered. */
@@ -1965,8 +1972,10 @@ setup(void)
* clients from the Unix socket, manging Wayland globals, and so on. */
dpy = wl_display_create();
- /* clean up child processes immediately */
+ /* Set up signal handlers */
sigchld(0);
+ signal(SIGINT, quitsignal);
+ signal(SIGTERM, quitsignal);
/* The backend is a wlroots feature which abstracts the underlying input and
* output hardware. The autocreate option will choose the most suitable