3 #if !defined(NO_SIGNALS) && defined(SIGPIPE)
4 extern volatile Sjmp_buf gPipeJmp
;
7 /* Read up to "size" bytes on sfd.
9 * If "retry" is on, after a successful read of less than "size"
10 * bytes, it will attempt to read more, upto "size."
12 * Although "retry" would seem to indicate you may want to always
13 * read "size" bytes or else it is an error, even with that on you
14 * may get back a value < size. Set "retry" to 0 when you want to
15 * return as soon as there is a chunk of data whose size is <= "size".
19 PRead(int sfd
, char *const buf0
, size_t size
, int retry
)
23 char *volatile buf
= buf0
;
24 #if !defined(NO_SIGNALS) && defined(SIGPIPE)
25 vsio_sigproc_t sigpipe
;
27 if (SSetjmp(gPipeJmp
) != 0) {
28 (void) SSignal(SIGPIPE
, (sio_sigproc_t
) sigpipe
);
33 return (kBrokenPipeErr
);
36 sigpipe
= (vsio_sigproc_t
) SSignal(SIGPIPE
, SIOHandler
);
42 nread
= read(sfd
, buf
, nleft
);
48 } else if (errno
!= EINTR
) {
60 if ((nleft
<= 0) || (retry
== 0))
67 #if !defined(NO_SIGNALS) && defined(SIGPIPE)
68 (void) SSignal(SIGPIPE
, (sio_sigproc_t
) sigpipe
);