diff options
author | David Robillard <d@drobilla.net> | 2018-09-29 11:38:08 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-11-10 11:45:15 +0100 |
commit | 29c7dd820c05ef334c7a2baa15d5b89502ea0444 (patch) | |
tree | d0cb4673ef436cd17711f66229b0413256371770 /src/jalv.c | |
parent | 84d5676be6648c29a972f58b0b920a772191c71e (diff) | |
download | jalv-29c7dd820c05ef334c7a2baa15d5b89502ea0444.tar.gz jalv-29c7dd820c05ef334c7a2baa15d5b89502ea0444.tar.bz2 jalv-29c7dd820c05ef334c7a2baa15d5b89502ea0444.zip |
Factor out signal setup
Diffstat (limited to 'src/jalv.c')
-rw-r--r-- | src/jalv.c | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -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(); |