-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherr.c
More file actions
37 lines (29 loc) · 680 Bytes
/
err.c
File metadata and controls
37 lines (29 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "err.h"
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
_Noreturn void syserr(const char* fmt, ...)
{
va_list fmt_args;
fprintf(stderr, "ERROR: ");
va_start(fmt_args, fmt);
vfprintf(stderr, fmt, fmt_args);
va_end(fmt_args);
fprintf(stderr, " (%d; %s)\n", errno, strerror(errno));
exit(1);
}
_Noreturn void fatal(const char* fmt, ...)
{
va_list fmt_args;
fprintf(stderr, "ERROR: ");
va_start(fmt_args, fmt);
vfprintf(stderr, fmt, fmt_args);
va_end(fmt_args);
fprintf(stderr, "\n");
exit(1);
}