wm: 5552

ref: f1addc2feef11d34311a9baa77ea0bda2bdf928b
dir: /unix.c/

View raw version
#include <stdio.h>
#include <stdlib.h>

_Noreturn void
sysfatal(char *fmt, ...)
{
	va_list arg;

	va_start(arg, fmt);
	vfprintf(stderr, fmt, arg);
	fprintf(stderr, "\n");
	va_end(arg);

	exit(1);
}

int
fprint(int fd, char *fmt, ...)
{
	int n;
	FILE *f;

	f = fdopen(fd, "w");

	va_list arg;
	va_start(arg, fmt);
	
	n = vfprintf(fd, fmt, arg);
	va_end(arg);

	fdclose(f);
	return n;
}