Skip to content

Commit

Permalink
mx_util: Add mx_die()
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Jan 10, 2024
1 parent c7f57d8 commit 956037e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions mx_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/syscall.h>
Expand Down

0 comments on commit 956037e

Please sign in to comment.