xref: /plan9/sys/src/libc/9sys/sysfatal.c (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
1 #include <u.h>
2 #include <libc.h>
3 
4 
5 static void
_sysfatalimpl(char * fmt,va_list arg)6 _sysfatalimpl(char *fmt, va_list arg)
7 {
8 	char buf[1024];
9 
10 	vseprint(buf, buf+sizeof(buf), fmt, arg);
11 	if(argv0)
12 		fprint(2, "%s: %s\n", argv0, buf);
13 	else
14 		fprint(2, "%s\n", buf);
15 	exits(buf);
16 }
17 
18 void (*_sysfatal)(char *fmt, va_list arg) = _sysfatalimpl;
19 
20 void
sysfatal(char * fmt,...)21 sysfatal(char *fmt, ...)
22 {
23 	va_list arg;
24 
25 	va_start(arg, fmt);
26 	(*_sysfatal)(fmt, arg);
27 	va_end(arg);
28 }
29