10 |
|
#include "copyright.h" |
11 |
|
|
12 |
|
#include <sys/types.h> |
13 |
< |
#include <sys/wait.h> /* XXX platform specific */ |
13 |
> |
#ifndef _WIN32 |
14 |
> |
#include <sys/wait.h> |
15 |
> |
#endif |
16 |
|
|
17 |
+ |
#include "paths.h" |
18 |
|
#include "platform.h" |
19 |
|
#include "standard.h" |
20 |
|
#include "driver.h" |
57 |
|
getstate(); |
58 |
|
/* set error vectors */ |
59 |
|
erract[COMMAND].pf = comm_comout; |
60 |
+ |
/* doesn't work with raypcalls.c |
61 |
|
if (erract[WARNING].pf != NULL) |
62 |
|
erract[WARNING].pf = comm_comout; |
63 |
+ |
*/ |
64 |
|
return(&comm_driver); |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
< |
extern struct driver * |
68 |
> |
struct driver * |
69 |
|
slave_init( /* run rview in slave mode */ |
70 |
|
char *dname, |
71 |
|
char *id |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
< |
extern struct driver * |
81 |
> |
struct driver * |
82 |
|
comm_init( /* set up and execute driver */ |
83 |
|
char *dname, |
84 |
|
char *id |
102 |
|
close(p2[0]); |
103 |
|
sprintf(pin, "%d", p1[0]); |
104 |
|
sprintf(pout, "%d", p2[1]); |
105 |
< |
execl(dvcname, dname, pin, pout, id, 0); |
105 |
> |
execl(dvcname, dname, pin, pout, id, NULL); |
106 |
|
perror(dvcname); |
107 |
|
_exit(127); |
108 |
|
} |
110 |
|
goto syserr; |
111 |
|
close(p1[0]); |
112 |
|
close(p2[1]); |
113 |
+ |
/* |
114 |
+ |
* Close write stream on exec to avoid multiprocessing deadlock. |
115 |
+ |
* No use in read stream without it, so set flag there as well. |
116 |
+ |
*/ |
117 |
+ |
fcntl(p1[1], F_SETFD, FD_CLOEXEC); |
118 |
+ |
fcntl(p2[0], F_SETFD, FD_CLOEXEC); |
119 |
|
if ((devout = fdopen(p1[1], "w")) == NULL) |
120 |
|
goto syserr; |
121 |
|
if ((devin = fdopen(p2[0], "r")) == NULL) |
147 |
|
fclose(devin); |
148 |
|
if (devchild < 0) |
149 |
|
return; |
150 |
+ |
#ifndef _WIN32 |
151 |
|
while ((pid = wait(0)) != -1 && pid != devchild) |
152 |
|
; |
153 |
+ |
#endif |
154 |
|
} |
155 |
|
|
156 |
|
|
250 |
|
|
251 |
|
static void |
252 |
|
mygets( /* get string from file (with nul) */ |
253 |
< |
register char *s, |
254 |
< |
register FILE *fp |
253 |
> |
char *s, |
254 |
> |
FILE *fp |
255 |
|
) |
256 |
|
{ |
257 |
< |
register int c; |
257 |
> |
int c; |
258 |
|
|
259 |
|
while ((c = getc(fp)) != EOF) |
260 |
|
if ((*s++ = c) == '\0') |
265 |
|
|
266 |
|
static void |
267 |
|
myputs( /* put string to file (with nul) */ |
268 |
< |
register char *s, |
269 |
< |
register FILE *fp |
268 |
> |
char *s, |
269 |
> |
FILE *fp |
270 |
|
) |
271 |
|
{ |
272 |
|
do |