24 |
|
disp_open(dname) /* open the named display driver */ |
25 |
|
char *dname; |
26 |
|
{ |
27 |
< |
char dpath[128], *com[3]; |
27 |
> |
char dpath[128], fd0[8], fd1[8], *cmd[5]; |
28 |
|
int i; |
29 |
< |
|
29 |
> |
/* get full display program name */ |
30 |
|
#ifdef DEVPATH |
31 |
|
sprintf(dpath, "%s/%s%s", DEVPATH, dname, HDSUF); |
32 |
|
#else |
33 |
|
sprintf(dpath, "dev/%s%s", dname, HDSUF); |
34 |
|
#endif |
35 |
< |
com[0] = dpath; com[1] = froot; com[2] = NULL; |
36 |
< |
i = open_process(dpd, com); |
35 |
> |
/* dup stdin and stdout */ |
36 |
> |
if (readinp) |
37 |
> |
sprintf(fd0, "%d", dup(0)); |
38 |
> |
else |
39 |
> |
strcpy(fd0, "-1"); |
40 |
> |
sprintf(fd1, "%d", dup(1)); |
41 |
> |
/* start the display process */ |
42 |
> |
cmd[0] = dpath; |
43 |
> |
cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0; |
44 |
> |
cmd[4] = NULL; |
45 |
> |
i = open_process(dpd, cmd); |
46 |
|
if (i <= 0) |
47 |
|
error(USER, "cannot start display process"); |
48 |
< |
if ((dpout = fdopen(dup(dpd[1]), "w")) == NULL) |
48 |
> |
if ((dpout = fdopen(dpd[1], "w")) == NULL) |
49 |
|
error(SYSTEM, "cannot associate FILE with display pipe"); |
50 |
+ |
dpd[1] = -1; /* causes ignored error in close_process() */ |
51 |
|
inp_flags = 0; |
52 |
+ |
/* close dup'ed stdin and stdout */ |
53 |
+ |
if (readinp) |
54 |
+ |
close(atoi(fd0)); |
55 |
+ |
close(atoi(fd1)); |
56 |
|
/* write out hologram grids */ |
57 |
|
for (i = 0; hdlist[i] != NULL; i++) |
58 |
|
disp_result(DS_ADDHOLO, sizeof(HDGRID), (char *)hdlist[i]); |