aboutsummaryrefslogtreecommitdiffstats
path: root/init/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/util.c')
-rw-r--r--init/util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/init/util.c b/init/util.c
new file mode 100644
index 0000000..1a08234
--- /dev/null
+++ b/init/util.c
@@ -0,0 +1,22 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void die(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+
+ if(fmt[0] && fmt[strlen(fmt)-1] == ':') {
+ fputc(' ', stderr);
+ perror(NULL);
+ } else {
+ fputc('\n', stderr);
+ }
+
+ exit(1);
+}