17 |
|
#include "rtprocess.h" /* getpid() */ |
18 |
|
#include "standard.h" |
19 |
|
#include "random.h" |
20 |
+ |
#include "ray.h" |
21 |
|
|
22 |
|
#ifdef F_SETLKW |
23 |
|
#include "paths.h" |
27 |
|
#define TIMELIM (8*3600) /* time limit for holding pattern */ |
28 |
|
#endif |
29 |
|
|
29 |
– |
extern void io_process(); |
30 |
– |
|
30 |
|
extern int headismine; /* boolean true if header belongs to me */ |
32 |
– |
|
31 |
|
extern char *progname; /* global program name */ |
34 |
– |
|
32 |
|
extern char *errfile; /* global error file name */ |
36 |
– |
|
33 |
|
static char *persistfname = NULL; /* persist file name */ |
34 |
|
static int persistfd = -1; /* persist file descriptor */ |
39 |
– |
|
35 |
|
static char inpname[TEMPLEN+1], outpname[TEMPLEN+1], errname[TEMPLEN+1]; |
36 |
|
|
37 |
+ |
typedef void (sighandler_t)(int); |
38 |
+ |
static sighandler_t sig_io; |
39 |
+ |
static sighandler_t sig_alrm; |
40 |
|
|
41 |
< |
void |
42 |
< |
pfdetach() /* release persist (and header) resources */ |
41 |
> |
|
42 |
> |
extern void |
43 |
> |
pfdetach(void) /* release persist (and header) resources */ |
44 |
|
{ |
45 |
|
if (persistfd >= 0) |
46 |
|
close(persistfd); |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
< |
void |
57 |
< |
pfclean() /* clean up persist files */ |
56 |
> |
extern void |
57 |
> |
pfclean(void) /* clean up persist files */ |
58 |
|
{ |
59 |
|
if (persistfd >= 0) |
60 |
|
close(persistfd); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
< |
void |
73 |
< |
pflock(lf) /* place or release exclusive lock on file */ |
74 |
< |
int lf; |
72 |
> |
extern void |
73 |
> |
pflock( /* place or release exclusive lock on file */ |
74 |
> |
int lf |
75 |
> |
) |
76 |
|
{ |
77 |
|
struct flock fls; |
78 |
|
|
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
< |
void |
89 |
< |
persistfile(pfn) /* open persist file and lock it */ |
90 |
< |
char *pfn; |
88 |
> |
extern void |
89 |
> |
persistfile( /* open persist file and lock it */ |
90 |
> |
char *pfn |
91 |
> |
) |
92 |
|
{ |
93 |
|
persistfd = open(pfn, O_WRONLY|O_CREAT|O_EXCL, 0644); |
94 |
|
if (persistfd >= 0) { |
109 |
|
|
110 |
|
static int got_io; |
111 |
|
|
112 |
< |
static void sig_io() { got_io++; } |
112 |
> |
static void sig_io(int i) { got_io++; } |
113 |
|
|
114 |
< |
static void sig_alrm() { quit(0); } |
114 |
> |
static void sig_alrm(int i) { quit(0); } |
115 |
|
|
116 |
|
|
117 |
< |
void |
118 |
< |
pfhold() /* holding pattern for idle rendering process */ |
117 |
> |
extern void |
118 |
> |
pfhold(void) /* holding pattern for idle rendering process */ |
119 |
|
{ |
120 |
< |
void (*oldalrm)(); |
120 |
> |
sighandler_t *oldalrm; |
121 |
|
char buf[512]; |
122 |
|
register int n; |
123 |
|
/* close input and output descriptors */ |
142 |
|
/* wait TIMELIM for someone to signal us */ |
143 |
|
got_io = 0; |
144 |
|
signal(SIGIO, sig_io); |
145 |
< |
oldalrm = (void (*)())signal(SIGALRM, sig_alrm); |
145 |
> |
oldalrm = signal(SIGALRM, sig_alrm); |
146 |
|
alarm(TIMELIM); |
147 |
|
pflock(0); /* unlock persist file for attach */ |
148 |
|
while (!got_io) |
185 |
|
} |
186 |
|
|
187 |
|
|
188 |
< |
void |
189 |
< |
io_process() /* just act as go-between for actual process */ |
188 |
> |
extern void |
189 |
> |
io_process(void) /* just act as go-between for actual process */ |
190 |
|
{ |
191 |
|
register char *cp; |
192 |
|
register int nr, n; |
335 |
|
} while ((nr -= n) > 0); |
336 |
|
} |
337 |
|
} |
338 |
< |
wait(0); /* wait for feeder process */ |
338 |
> |
wait(0); /* wait for feeder process */ /* XXX platform */ |
339 |
|
_exit(status); |
340 |
|
formerr: |
341 |
|
error(USER, "format error in persist file"); |
347 |
|
|
348 |
|
#else |
349 |
|
|
350 |
< |
void pfclean() {} |
350 |
> |
extern void pfclean(void) {} |
351 |
|
|
352 |
|
#endif |