summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4b79d75)
raw | patch | inline | side by side (parent: 4b79d75)
author | Max Kellermann <max.kellermann@gmail.com> | |
Sun, 19 Mar 2017 10:41:00 +0000 (11:41 +0100) | ||
committer | Max Kellermann <max.kellermann@gmail.com> | |
Sun, 19 Mar 2017 10:41:00 +0000 (11:41 +0100) |
Unfortunately, GLib doesn't support SIGWINCH and SIGCONT, for whatever
reasons.
reasons.
src/main.c | patch | blob | history |
diff --git a/src/main.c b/src/main.c
index 953f715afeaa81af9eba12d75f7e0af064ceaa30..214478e39ded84a53a3ac96591888e7f96c0d19c 100644 (file)
--- a/src/main.c
+++ b/src/main.c
#include <mpd/client.h>
+#ifndef WIN32
+#include <glib-unix.h>
+#endif
+
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#endif
#ifndef WIN32
-static void
-catch_sigint(gcc_unused int sig)
+static gboolean
+handle_quit_signal(gcc_unused gpointer data)
{
g_main_loop_quit(main_loop);
+ return false;
}
static gboolean
options_parse(argc, argv);
#ifndef WIN32
- /* setup signal behavior - SIGINT */
+ /* setup quit signals */
+ g_unix_signal_add(SIGTERM, handle_quit_signal, NULL);
+ g_unix_signal_add(SIGINT, handle_quit_signal, NULL);
+ g_unix_signal_add(SIGHUP, handle_quit_signal, NULL);
+
+ /* setup signal behavior - SIGCONT */
+
struct sigaction act;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
- act.sa_handler = catch_sigint;
- if (sigaction(SIGINT, &act, NULL) < 0) {
- perror("signal");
- exit(EXIT_FAILURE);
- }
-
- /* setup signal behavior - SIGTERM */
-
- act.sa_handler = catch_sigint;
- if (sigaction(SIGTERM, &act, NULL) < 0) {
- perror("sigaction()");
- exit(EXIT_FAILURE);
- }
-
- /* setup signal behavior - SIGCONT */
act.sa_handler = catch_sigwinch;
if (sigaction(SIGCONT, &act, NULL) < 0) {
exit(EXIT_FAILURE);
}
- /* setup signal behaviour - SIGHUP*/
-
- act.sa_handler = catch_sigint;
- if (sigaction(SIGHUP, &act, NULL) < 0) {
- perror("sigaction(SIGHUP)");
- exit(EXIT_FAILURE);
- }
-
/* setup SIGWINCH */
act.sa_flags = SA_RESTART;