-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy patherrors.c
More file actions
36 lines (31 loc) · 704 Bytes
/
Copy patherrors.c
File metadata and controls
36 lines (31 loc) · 704 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
#include <stdio.h>
#include <stdarg.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <string.h>
FILE *log_fp=NULL;
int logprintf(char *progname, char *msg,...) {
int n;
va_list ap;
va_start(ap, msg);
fprintf(log_fp,";;; %s: %ld: ",progname,time(0));
n=vfprintf(log_fp,msg,ap);
va_end(ap);
fprintf(log_fp,"\n");
return n;
}
void bail(char *progname,char *msg,...) {
int n;
va_list ap;
int e=errno;
va_start(ap, msg);
fprintf(log_fp,";;; %s: %ld: FATAL ",progname,time(0));
n=vfprintf(log_fp,msg,ap);
va_end(ap);
if(e>0)
fprintf(log_fp," (%s)\n",strerror(e));
else
fputc('\n',log_fp);
kill(getpid(),15);
}