aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-09-29 11:38:08 +0200
committerDavid Robillard <d@drobilla.net>2018-11-10 11:45:15 +0100
commit29c7dd820c05ef334c7a2baa15d5b89502ea0444 (patch)
treed0cb4673ef436cd17711f66229b0413256371770
parent84d5676be6648c29a972f58b0b920a772191c71e (diff)
downloadjalv-29c7dd820c05ef334c7a2baa15d5b89502ea0444.tar.gz
jalv-29c7dd820c05ef334c7a2baa15d5b89502ea0444.tar.bz2
jalv-29c7dd820c05ef334c7a2baa15d5b89502ea0444.zip
Factor out signal setup
-rw-r--r--src/jalv.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/jalv.c b/src/jalv.c
index e2bda2f..ff20432 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -728,6 +728,23 @@ signal_handler(ZIX_UNUSED int sig)
zix_sem_post(&exit_sem);
}
+static void
+setup_signals(void)
+{
+#ifdef HAVE_SIGACTION
+ struct sigaction action;
+ sigemptyset(&action.sa_mask);
+ action.sa_flags = 0;
+ action.sa_handler = signal_handler;
+ sigaction(SIGINT, &action, NULL);
+ sigaction(SIGTERM, &action, NULL);
+#else
+ /* May not work in combination with fgets in the console interface */
+ signal(SIGINT, signal_handler);
+ signal(SIGTERM, signal_handler);
+#endif
+}
+
int
jalv_open(Jalv* const jalv, int argc, char** argv)
{
@@ -837,18 +854,7 @@ jalv_open(Jalv* const jalv, int argc, char** argv)
zix_sem_init(&jalv->paused, 0);
zix_sem_init(&jalv->worker.sem, 0);
-#ifdef HAVE_SIGACTION
- struct sigaction action;
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
- action.sa_handler = signal_handler;
- sigaction(SIGINT, &action, NULL);
- sigaction(SIGTERM, &action, NULL);
-#else
- /* May not work in combination with fgets in the console interface */
- signal(SIGINT, signal_handler);
- signal(SIGTERM, signal_handler);
-#endif
+ setup_signals();
/* Find all installed plugins */
LilvWorld* world = lilv_world_new();