18 |
|
|
19 |
|
static int inp_flags; |
20 |
|
static int dpd[3]; |
21 |
– |
static int pipesiz; |
21 |
|
static FILE *dpout; |
22 |
|
|
23 |
|
|
33 |
|
sprintf(dpath, "dev/%s%s", dname, HDSUF); |
34 |
|
#endif |
35 |
|
com[0] = dpath; com[1] = froot; com[2] = NULL; |
36 |
< |
pipesiz = open_process(dpd, com); |
37 |
< |
if (pipesiz <= 0) |
36 |
> |
i = open_process(dpd, com); |
37 |
> |
if (i <= 0) |
38 |
|
error(USER, "cannot start display process"); |
39 |
|
if ((dpout = fdopen(dup(dpd[1]), "w")) == NULL) |
40 |
|
error(SYSTEM, "cannot associate FILE with display pipe"); |
60 |
|
int n; |
61 |
|
char *buf = NULL; |
62 |
|
|
63 |
< |
if (pipesiz <= 0) |
63 |
> |
if (dpout == NULL) |
64 |
|
return(-1); |
65 |
|
/* flush display output */ |
66 |
|
disp_flush(); |
73 |
|
/* read message header */ |
74 |
|
n = read(dpd[0], (char *)&msg, sizeof(MSGHEAD)); |
75 |
|
if (n != sizeof(MSGHEAD)) { |
76 |
< |
if (n >= 0) |
76 |
> |
if (n >= 0) { |
77 |
> |
dpout = NULL; |
78 |
|
error(USER, "display process died"); |
79 |
+ |
} |
80 |
|
if (errno != EAGAIN & errno != EINTR) |
81 |
|
goto readerr; |
82 |
|
return(2); /* acceptable failure */ |
110 |
|
disp_result(DS_STARTIMM, 0, NULL); |
111 |
|
bundle_set(BS_ADD, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD)); |
112 |
|
disp_result(DS_ENDIMM, 0, NULL); |
113 |
+ |
disp_check(0); /* hack -- delete usu. follows add */ |
114 |
+ |
break; |
115 |
+ |
case DR_ADJSET: |
116 |
+ |
if (msg.nbytes % sizeof(PACKHEAD)) |
117 |
+ |
error(INTERNAL, "bad DR_ADJSET from display process"); |
118 |
+ |
disp_result(DS_STARTIMM, 0, NULL); |
119 |
+ |
bundle_set(BS_ADJ, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD)); |
120 |
+ |
disp_result(DS_ENDIMM, 0, NULL); |
121 |
|
disp_flush(); |
122 |
|
break; |
123 |
|
case DR_DELSET: |
135 |
|
if (msg.nbytes) |
136 |
|
error(INTERNAL, "bad DR_SHUTDOWN from display process"); |
137 |
|
return(0); /* zero return signals shutdown */ |
138 |
+ |
case DR_NOOP: |
139 |
+ |
break; |
140 |
|
default: |
141 |
|
error(INTERNAL, "unrecognized request from display process"); |
142 |
|
} |
155 |
|
{ |
156 |
|
int rval; |
157 |
|
|
158 |
< |
if (pipesiz <= 0) |
158 |
> |
if (dpout == NULL) |
159 |
|
return(-1); |
160 |
|
disp_result(DS_SHUTDOWN, 0, NULL); |
161 |
|
fclose(dpout); |
162 |
|
dpout = NULL; |
152 |
– |
pipesiz = 0; |
163 |
|
return(close_process(dpd)); |
164 |
|
} |
165 |
|
|
170 |
|
{ |
171 |
|
MSGHEAD msg; |
172 |
|
|
173 |
+ |
if (dpout == NULL) |
174 |
+ |
return; |
175 |
|
msg.type = type; |
176 |
|
msg.nbytes = nbytes; |
177 |
|
fwrite((char *)&msg, sizeof(MSGHEAD), 1, dpout); |