logo

inaban

Unnamed repository; edit this file 'description' to name the repository.
commit: ed07a9cb8f25cb592ebed778997ea769a98c3dba
parent: 8949d5e429c658c169f1c2d8a10c1637b4c289f3
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon,  1 Jul 2019 08:34:27 +0200

Properly handle SIGTERM

Diffstat:

Minaban.c15++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/inaban.c b/inaban.c @@ -4,11 +4,14 @@ #include "config.h" #include <getopt.h> +#include <signal.h> /* signal(), SIGTERM */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> +struct inaban_server server = {0}; + static void focus_view(struct inaban_view *view, struct wlr_surface *surface) { @@ -787,6 +790,14 @@ drop_permissions(void) return true; } +void +sigterm_handler(int signal) +{ + (void)signal; + wl_display_terminate(server.wl_display); + exit(EXIT_SUCCESS); +} + int main(int argc, char *argv[]) { @@ -814,7 +825,6 @@ main(int argc, char *argv[]) sleep(5); } - struct inaban_server server; /* The Wayland display is managed by libwayland. It handles accepting * clients from the Unix socket, manging Wayland globals, and so on. */ server.wl_display = wl_display_create(); @@ -830,6 +840,9 @@ main(int argc, char *argv[]) if(!drop_permissions()) abort(); + // handle SIGTERM signals + signal(SIGTERM, sigterm_handler); + /* If we don't provide a renderer, autocreate makes a GLES2 renderer for us. * The renderer is responsible for defining the various pixel formats it * supports for shared memory, this configures that for clients. */