summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-02-17 22:58:37 +0100
committerLouis Burda <quent.burda@gmail.com>2023-02-17 22:58:37 +0100
commita08e917dbb2310fbc5852e675992b6fd5499cb86 (patch)
tree6dcdfe462e8b27c2eaf091aa55dae3fcf0b2f7bd /src/main.c
parent4efa0d0f0303be076d013c61a83b2d769778f37d (diff)
downloadtmus-a08e917dbb2310fbc5852e675992b6fd5499cb86.tar.gz
tmus-a08e917dbb2310fbc5852e675992b6fd5499cb86.zip
Use SIGINT to stop player and update player status less frequently
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index dbb76ae..024293c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4,12 +4,24 @@
#include "player.h"
#include "tui.h"
+#include <curses.h>
#include <locale.h>
+static void stop(int sig);
static void init(void);
static void cleanup(int code, void *arg);
void
+stop(int sig)
+{
+ if (player.loaded) {
+ player_stop();
+ } else {
+ exit(0);
+ }
+}
+
+void
init(void)
{
setlocale(LC_ALL, "");
@@ -26,7 +38,7 @@ init(void)
dbus_init();
on_exit(cleanup, NULL);
- signal(SIGINT, exit);
+ signal(SIGINT, stop);
signal(SIGTERM, exit);
signal(SIGKILL, exit);
}