diff --git a/mx_util.c b/mx_util.c index c7d5182..8818570 100644 --- a/mx_util.c +++ b/mx_util.c @@ -1414,3 +1414,11 @@ char *mx_pipe_external(char *helper, char **argv) { errno = err; return NULL; } + +void mx_die(const char *restrict fmt, ...) { + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + _exit(1); +} diff --git a/mx_util.h b/mx_util.h index f64a696..8baad02 100644 --- a/mx_util.h +++ b/mx_util.h @@ -183,6 +183,8 @@ int mx_fs_get_sizes(const char *path, unsigned long *free, unsigned long *total) time_t mx_clock_boottime(void); int mx_call_external(char *helper, char **argv); char *mx_pipe_external(char *args, char **argv); +void mx_die(const char *restrict fmt, ...) __attribute__ ((noreturn,format (printf, 1, 2))); + #if __GLIBC__ <2 || __GLIBC__ == 2 && __GLIBC_MINOR__ < 34 #include