4 |
|
/* |
5 |
|
* Routines to communicate with separate process via dual pipes |
6 |
|
* |
7 |
< |
* External symbols declared in standard.h |
7 |
> |
* External symbols declared in rtprocess.h |
8 |
|
*/ |
9 |
|
|
10 |
|
#include "copyright.h" |
23 |
|
|
24 |
|
int |
25 |
|
process( /* process data through pd */ |
26 |
< |
SUBPROC *pd, |
27 |
< |
char *recvbuf, char *sendbuf, |
28 |
< |
int nbr, int nbs |
26 |
> |
SUBPROC *pd, |
27 |
> |
char *recvbuf, char *sendbuf, |
28 |
> |
int nbr, int nbs |
29 |
|
) |
30 |
|
{ |
31 |
< |
if (nbs > PIPE_BUF) |
31 |
> |
if (!(pd->flags & PF_RUNNING)) |
32 |
|
return(-1); |
33 |
– |
if (!pd->running) |
34 |
– |
return(-1); |
33 |
|
if (writebuf(pd->w, sendbuf, nbs) < nbs) |
34 |
|
return(-1); |
35 |
|
return(readbuf(pd->r, recvbuf, nbr)); |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
< |
int |
40 |
> |
ssize_t |
41 |
|
readbuf( /* read all of requested buffer */ |
42 |
< |
int fd, |
43 |
< |
char *bpos, |
44 |
< |
int siz |
42 |
> |
int fd, |
43 |
> |
char *bpos, |
44 |
> |
ssize_t siz |
45 |
|
) |
46 |
|
{ |
47 |
< |
register int cc = 0, nrem = siz; |
47 |
> |
ssize_t cc = 0, nrem = siz; |
48 |
|
retry: |
49 |
|
while (nrem > 0 && (cc = read(fd, bpos, nrem)) > 0) { |
50 |
|
bpos += cc; |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
< |
int |
64 |
> |
ssize_t |
65 |
|
writebuf( /* write all of requested buffer */ |
66 |
|
int fd, |
67 |
|
char *bpos, |
68 |
< |
int siz |
68 |
> |
ssize_t siz |
69 |
|
) |
70 |
|
{ |
71 |
< |
register int cc = 0, nrem = siz; |
71 |
> |
ssize_t cc = 0, nrem = siz; |
72 |
|
retry: |
73 |
|
while (nrem > 0 && (cc = write(fd, bpos, nrem)) > 0) { |
74 |
|
bpos += cc; |