From 3bf4d129111b94b421a9f6b4d63c2aab42c367c3 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Wed, 8 Feb 2017 17:05:52 +0100 Subject: [PATCH] gluon-radv-filterd: Ship with own implementation of error() --- .../src/gluon-radv-filterd.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/package/gluon-radv-filterd/src/gluon-radv-filterd.c b/package/gluon-radv-filterd/src/gluon-radv-filterd.c index 848cd7a5..b85a2084 100644 --- a/package/gluon-radv-filterd/src/gluon-radv-filterd.c +++ b/package/gluon-radv-filterd/src/gluon-radv-filterd.c @@ -24,7 +24,6 @@ */ #define _GNU_SOURCE -#include #include #include #include @@ -123,6 +122,18 @@ struct global { }; +static void error(int status, int errnum, char *message, ...) { + va_list ap; + va_start(ap, message); + fflush(stdout); + vfprintf(stderr, message, ap); + if (errnum) + fprintf(stderr, ": %s", strerror(errnum)); + fprintf(stderr, "\n"); + if (status) + exit(status); +} + static void cleanup() { struct router *router; close(G.sock); @@ -464,7 +475,7 @@ static int fork_execvp_timeout(struct timespec *timeout, const char *file, const if (ret == SIGCHLD) { if (info.si_pid != child) { cleanup(); - error_at_line(1, 0, __FILE__, __LINE__, + error(1, 0, "BUG: We received a SIGCHLD from a child we didn't spawn (expected PID %d, got %d)", child, info.si_pid); } @@ -479,8 +490,8 @@ static int fork_execvp_timeout(struct timespec *timeout, const char *file, const else if (ret < 0) warn_errno("sigtimedwait failed, killing child"); else - error_at_line(1, 0, __FILE__, __LINE__, - "BUG: sigtimedwait() return some other signal than SIGCHLD: %d", + error(1, 0, + "BUG: sigtimedwait() returned some other signal than SIGCHLD: %d", ret); kill(child, SIGKILL);