10 |
|
|
11 |
|
#include "standard.h" |
12 |
|
#include <fcntl.h> |
13 |
+ |
#include <signal.h> |
14 |
|
#include "color.h" |
15 |
|
#include "view.h" |
16 |
|
#include "resolu.h" |
36 |
|
|
37 |
|
extern long lseek(), ftell(); |
38 |
|
|
39 |
+ |
int gotalrm = 0; |
40 |
+ |
int onalrm() { gotalrm++; } |
41 |
|
|
42 |
+ |
|
43 |
|
main(argc, argv) |
44 |
|
int argc; |
45 |
|
char *argv[]; |
188 |
|
fprintf(stderr, "%s: out of memory\n", progname); |
189 |
|
exit(1); |
190 |
|
} |
191 |
+ |
signal(SIGALRM, onalrm); |
192 |
|
return; |
193 |
|
filerr: |
194 |
|
fprintf(stderr, "%s: file i/o error\n", outfile); |
204 |
|
struct flock fls; |
205 |
|
char buf[64]; |
206 |
|
|
207 |
< |
if (syncfd != -1) { /* using sync file */ |
207 |
> |
if (gotalrm) /* someone wants us to quit */ |
208 |
> |
return(0); |
209 |
> |
if (syncfd != -1) { /* use sync file */ |
210 |
|
fls.l_type = F_WRLCK; /* gain exclusive access */ |
211 |
|
fls.l_whence = 0; |
212 |
|
fls.l_start = 0L; |
232 |
|
fcntl(syncfd, F_SETLKW, &fls); |
233 |
|
return(1); |
234 |
|
} |
235 |
< |
if (fgets(buf, sizeof(buf), stdin) == NULL) /* using stdin */ |
235 |
> |
if (fgets(buf, sizeof(buf), stdin) == NULL) /* use stdin */ |
236 |
|
return(0); |
237 |
|
if (sscanf(buf, "%d %d", xp, yp) == 2) |
238 |
|
return(1); |