diff options
author | Laxmi Devi <Laxmi.Devi@in.bosch.com> | 2018-05-24 15:04:23 +0530 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-09-20 09:27:49 +0200 |
commit | ff06bedf007a48407b728e9d35dc4bd2daad8314 (patch) | |
tree | dbd549d12a1a338d55ccfe4d104a9782d0a18965 | |
parent | 43dd0b6fd560f97e2584364593c5e44f2262c281 (diff) | |
download | jalv-ff06bedf007a48407b728e9d35dc4bd2daad8314.tar.gz jalv-ff06bedf007a48407b728e9d35dc4bd2daad8314.tar.bz2 jalv-ff06bedf007a48407b728e9d35dc4bd2daad8314.zip |
Use sigaction() instead of signal()fix-ctrl-c-hang
Issue is that even after ctrl+c, fgets is waiting for a newline.
See signal(7) for details. We have to either use siginterrupt() together with
signal(), or use sigaction() instead of signal() for registering the signal
handler, in order to disable restarting a read() system call after a signal.
Signed-off-by: Laxmi Devi <Laxmi.Devi@in.bosch.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/jalv.c | 10 | ||||
-rw-r--r-- | wscript | 6 |
3 files changed, 18 insertions, 1 deletions
@@ -4,10 +4,11 @@ jalv (1.6.1) unstable; * Add jalv -i option to ignore stdin for background use * Fix Jack deactivation * Fix potential crash when closed with worker (thanks JP Cimalando) + * Fix potential hang after Ctrl-c in console interface (thanks Laxmi Devi) * Add support for underscore in port names on command line (thanks Jośe Fernando Moyano) - -- David Robillard <d@drobilla.net> Thu, 20 Sep 2018 09:21:15 +0200 + -- David Robillard <d@drobilla.net> Thu, 20 Sep 2018 09:27:15 +0200 jalv (1.6.0) stable; @@ -878,8 +878,18 @@ main(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 /* Find all installed plugins */ LilvWorld* world = lilv_world_new(); @@ -120,6 +120,12 @@ def configure(conf): define_name = 'HAVE_MLOCK', mandatory = False) + autowaf.check_function(conf, 'c', 'sigaction', + header_name = 'signal.h', + defines = defines, + define_name = 'HAVE_SIGACTION', + mandatory = False) + if conf.is_defined('HAVE_ISATTY') and conf.is_defined('HAVE_FILENO'): autowaf.define(conf, 'JALV_WITH_COLOR', 1) conf.env.append_unique('CFLAGS', ['-D_POSIX_C_SOURCE=200809L']) |