From 399a5586a60b81daf483d543adefd025e705c6ed Mon Sep 17 00:00:00 2001 From: Laxmi Devi Date: Thu, 24 May 2018 15:04:23 +0530 Subject: Use sigaction() instead of signal() 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 Signed-off-by: Timo Wischer --- src/jalv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/jalv.c b/src/jalv.c index b95e7d4..d25a8b2 100644 --- a/src/jalv.c +++ b/src/jalv.c @@ -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(); -- cgit v1.2.1