1 #include <errno.h> 2 #include <stdarg.h> 3 #include <stdio.h> 4 #include <stdlib.h> 5 #include <sys/types.h> 6 #include <signal.h> 7 error_exit(char * format,...)8void error_exit(char *format, ...) 9 { 10 va_list ap; 11 12 fflush(NULL); 13 14 va_start(ap, format); 15 (void)vfprintf(stderr, format, ap); 16 va_end(ap); 17 fprintf(stderr, "errno=%d (if applicable)\n", errno); 18 19 exit(EXIT_FAILURE); 20 } 21 22