| 14 |
|
#include <sys/types.h> |
| 15 |
|
#include <sys/stat.h> |
| 16 |
|
|
| 17 |
+ |
#ifndef TIMELIM |
| 18 |
+ |
#define TIMELIM (8*3600) /* time limit for holding pattern */ |
| 19 |
+ |
#endif |
| 20 |
+ |
|
| 21 |
|
extern char *strcpy(), *index(); |
| 22 |
|
|
| 23 |
|
extern int headismine; /* boolean true if header belongs to me */ |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
|
| 90 |
< |
sig_noop() {} |
| 90 |
> |
int sig_noop() {} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
pfhold() /* holding pattern for idle rendering process */ |
| 96 |
|
register int n; |
| 97 |
|
/* close input and output descriptors */ |
| 98 |
|
close(fileno(stdin)); |
| 95 |
– |
fflush(stdout); |
| 99 |
|
close(fileno(stdout)); |
| 100 |
|
/* create named pipes for input and output */ |
| 101 |
|
if (mknod(mktemp(strcpy(inpname,TEMPLATE)), S_IFIFO|0600) < 0) |
| 108 |
|
n = strlen(buf); |
| 109 |
|
if (write(persistfd, buf, n) < n) |
| 110 |
|
error(SYSTEM, "error writing persist file in pfhold"); |
| 111 |
< |
/* wait for someone to signal us */ |
| 112 |
< |
signal(SIGALRM, sig_noop); |
| 111 |
> |
/* wait TIMELIM for someone to signal us */ |
| 112 |
> |
signal(SIGIO, sig_noop); |
| 113 |
> |
alarm(TIMELIM); |
| 114 |
|
pflock(0); |
| 115 |
|
pause(); |
| 116 |
+ |
alarm(0); |
| 117 |
+ |
signal(SIGIO, SIG_DFL); |
| 118 |
|
pflock(1); |
| 119 |
|
/* someone wants us; reopen stdin and stdout */ |
| 120 |
|
if (freopen(inpname, "r", stdin) == NULL) |
| 125 |
|
inpname[0] = '\0'; |
| 126 |
|
unlink(outpname); |
| 127 |
|
outpname[0] = '\0'; |
| 128 |
+ |
clean_slate(); /* reset time and ray counters */ |
| 129 |
|
return; |
| 130 |
|
createrr: |
| 131 |
|
error(SYSTEM, "cannot create named pipes in pfhold"); |
| 162 |
|
if (cp-buf != nr) |
| 163 |
|
goto formerr; |
| 164 |
|
/* wake up rendering process */ |
| 165 |
< |
if (kill(pid, SIGALRM) < 0) |
| 165 |
> |
if (kill(pid, SIGIO) < 0) |
| 166 |
|
error(SYSTEM, "cannot signal rendering process in io_process"); |
| 167 |
|
pid = fork(); /* fork i/o process */ |
| 168 |
|
if (pid < 0) |