13 |
|
#include <sys/uio.h> |
14 |
|
|
15 |
|
#ifndef HDSUF |
16 |
< |
#define HDSUF ".hdi" |
16 |
> |
#define HDSUF ".hdi" |
17 |
|
#endif |
18 |
+ |
#ifndef SLAVENAME |
19 |
+ |
#define SLAVENAME "slave" |
20 |
+ |
#endif |
21 |
|
|
22 |
|
#ifndef FNONBLK |
23 |
|
#define FNONBLK O_NONBLOCK |
33 |
|
{ |
34 |
|
char buf[sizeof(HDGRID)+512], fd0[8], fd1[8], *cmd[5], *sfn; |
35 |
|
int i, n, len; |
36 |
< |
/* get full display program name */ |
36 |
> |
|
37 |
> |
if (!strcmp(dname, SLAVENAME)) { |
38 |
> |
dpd[0] = 0; /* read from stdin */ |
39 |
> |
dpout = stdout; /* write to stdout */ |
40 |
> |
dpd[2] = -1; /* we're the slave process */ |
41 |
> |
} else { |
42 |
> |
/* get full display program name */ |
43 |
|
#ifdef DEVPATH |
44 |
< |
sprintf(buf, "%s/%s%s", DEVPATH, dname, HDSUF); |
44 |
> |
sprintf(buf, "%s/%s%s", DEVPATH, dname, HDSUF); |
45 |
|
#else |
46 |
< |
sprintf(buf, "dev/%s%s", dname, HDSUF); |
46 |
> |
sprintf(buf, "dev/%s%s", dname, HDSUF); |
47 |
|
#endif |
48 |
< |
/* dup stdin and stdout */ |
49 |
< |
if (readinp) |
50 |
< |
sprintf(fd0, "%d", dup(0)); |
51 |
< |
else |
52 |
< |
strcpy(fd0, "-1"); |
53 |
< |
sprintf(fd1, "%d", dup(1)); |
54 |
< |
/* start the display process */ |
55 |
< |
cmd[0] = buf; |
56 |
< |
cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0; |
57 |
< |
cmd[4] = NULL; |
58 |
< |
i = open_process(dpd, cmd); |
59 |
< |
if (i <= 0) |
60 |
< |
error(USER, "cannot start display process"); |
61 |
< |
if ((dpout = fdopen(dpd[1], "w")) == NULL) |
62 |
< |
error(SYSTEM, "cannot associate FILE with display pipe"); |
48 |
> |
/* dup stdin and stdout */ |
49 |
> |
if (readinp) |
50 |
> |
sprintf(fd0, "%d", dup(0)); |
51 |
> |
else |
52 |
> |
strcpy(fd0, "-1"); |
53 |
> |
sprintf(fd1, "%d", dup(1)); |
54 |
> |
/* start the display process */ |
55 |
> |
cmd[0] = buf; |
56 |
> |
cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0; |
57 |
> |
cmd[4] = NULL; |
58 |
> |
i = open_process(dpd, cmd); |
59 |
> |
if (i <= 0) |
60 |
> |
error(USER, "cannot start display process"); |
61 |
> |
if ((dpout = fdopen(dpd[1], "w")) == NULL) |
62 |
> |
error(SYSTEM, "problem opening display pipe"); |
63 |
> |
/* close dup'ed stdin and stdout */ |
64 |
> |
if (readinp) |
65 |
> |
close(atoi(fd0)); |
66 |
> |
close(atoi(fd1)); |
67 |
> |
} |
68 |
|
dpd[1] = -1; /* causes ignored error in close_process() */ |
69 |
|
inp_flags = 0; |
56 |
– |
/* close dup'ed stdin and stdout */ |
57 |
– |
if (readinp) |
58 |
– |
close(atoi(fd0)); |
59 |
– |
close(atoi(fd1)); |
70 |
|
/* check if outside */ |
71 |
|
if (vdef(OBSTRUCTIONS) && vbool(OBSTRUCTIONS)) |
72 |
|
disp_result(DS_OUTSECT, 0, NULL); |
253 |
|
disp_result(DS_SHUTDOWN, 0, NULL); |
254 |
|
fclose(dpout); |
255 |
|
dpout = NULL; |
256 |
< |
return(close_process(dpd)); |
256 |
> |
return(dpd[2]<0 ? 0 : close_process(dpd)); |
257 |
|
} |
258 |
|
|
259 |
|
|