46 |
|
disp_packet(p) /* display a packet */ |
47 |
|
register PACKET *p; |
48 |
|
{ |
49 |
– |
if (pipesiz <= 0) |
50 |
– |
return; |
49 |
|
disp_result(DS_BUNDLE, sizeof(PACKHEAD) + p->nr*sizeof(RAYVAL), |
50 |
|
(char *)p); |
51 |
|
} |
60 |
|
|
61 |
|
if (pipesiz <= 0) |
62 |
|
return(-1); |
63 |
< |
restart: /* check read blocking */ |
63 |
> |
/* check read blocking */ |
64 |
|
if (block != (inp_flags == 0)) { |
65 |
|
inp_flags = block ? 0 : FNONBLK; |
66 |
|
if (fcntl(dpd[0], F_SETFL, inp_flags) < 0) |
73 |
|
error(USER, "display process died"); |
74 |
|
if (errno != EAGAIN & errno != EINTR) |
75 |
|
goto readerr; |
76 |
< |
return(2); /* else acceptable failure */ |
76 |
> |
return(2); /* acceptable failure */ |
77 |
|
} |
78 |
|
if (msg.nbytes) { /* get the message body */ |
79 |
|
buf = (char *)malloc(msg.nbytes); |
114 |
|
error(INTERNAL, "bad DR_ATTEN from display process"); |
115 |
|
/* send acknowledgement */ |
116 |
|
disp_result(DS_ACKNOW, 0, NULL); |
117 |
< |
block = 1; /* block on following request */ |
120 |
< |
goto restart; |
117 |
> |
return(disp_check(1)); /* block on following request */ |
118 |
|
case DR_SHUTDOWN: |
119 |
|
if (msg.nbytes) |
120 |
|
error(INTERNAL, "bad DR_SHUTDOWN from display process"); |
122 |
|
default: |
123 |
|
error(INTERNAL, "unrecognized request from display process"); |
124 |
|
} |
125 |
< |
if (msg.nbytes) |
125 |
> |
if (msg.nbytes) /* clean up */ |
126 |
|
free(buf); |
127 |
|
return(1); /* normal return value */ |
128 |
|
fcntlerr: |
153 |
|
MSGHEAD msg; |
154 |
|
int n; |
155 |
|
|
156 |
+ |
if (pipesiz <= 0) |
157 |
+ |
return; |
158 |
|
msg.type = type; |
159 |
|
msg.nbytes = nbytes; |
160 |
|
if (nbytes == 0 || sizeof(MSGHEAD)+nbytes > pipesiz) { |
161 |
< |
n = write(dpd[1], (char *)&msg, sizeof(MSGHEAD)); |
161 |
> |
do |
162 |
> |
n = write(dpd[1], (char *)&msg, sizeof(MSGHEAD)); |
163 |
> |
while (n < 0 && errno == EINTR); |
164 |
|
if (n != sizeof(MSGHEAD)) |
165 |
|
goto writerr; |
166 |
|
if (nbytes > 0) { |
174 |
|
iov[0].iov_len = sizeof(MSGHEAD); |
175 |
|
iov[1].iov_base = p; |
176 |
|
iov[1].iov_len = nbytes; |
177 |
< |
n = writev(dpd[1], iov, 2); |
178 |
< |
if (n == nbytes+sizeof(MSGHEAD)) |
177 |
> |
do |
178 |
> |
n = writev(dpd[1], iov, 2); |
179 |
> |
while (n < 0 && errno == EINTR); |
180 |
> |
if (n == sizeof(MSGHEAD)+nbytes) |
181 |
|
return; |
182 |
|
writerr: |
183 |
|
error(SYSTEM, "write error in disp_result"); |