From ec710f8a172246cde2cf66b3b63ec8cba3a44a62 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 4 Sep 2017 16:20:37 +0200 Subject: [PATCH] allow usage of error() and killme() without previous call to signals_init() --- lib/utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/utils.c b/lib/utils.c index a94e7c45b..7239beb63 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -336,7 +336,11 @@ int signals_init(void (*cb)(int signal, siginfo_t *sinfo, void *ctx)) void killme(int sig) { - pthread_kill(main_thread, sig); + /* Send only to main thread in case the ID was initilized by signals_init() */ + if (main_thread) + pthread_kill(main_thread, sig); + else + kill(0, sig); } pid_t spawn(const char* name, char *const argv[])