@@ -100,24 +100,6 @@ pub fn read2(p1: AnonPipe,
100100 // wait for either pipe to become readable using `poll`
101101 cvt_r ( || unsafe { libc:: poll ( fds. as_mut_ptr ( ) , 2 , -1 ) } ) ?;
102102
103- // Read as much as we can from each pipe, ignoring EWOULDBLOCK or
104- // EAGAIN. If we hit EOF, then this will happen because the underlying
105- // reader will return Ok(0), in which case we'll see `Ok` ourselves. In
106- // this case we flip the other fd back into blocking mode and read
107- // whatever's leftover on that file descriptor.
108- let read = |fd : & FileDesc , dst : & mut Vec < u8 > | {
109- match fd. read_to_end ( dst) {
110- Ok ( _) => Ok ( true ) ,
111- Err ( e) => {
112- if e. raw_os_error ( ) == Some ( libc:: EWOULDBLOCK ) ||
113- e. raw_os_error ( ) == Some ( libc:: EAGAIN ) {
114- Ok ( false )
115- } else {
116- Err ( e)
117- }
118- }
119- }
120- } ;
121103 if fds[ 0 ] . revents != 0 && read ( & p1, v1) ? {
122104 p2. set_nonblocking ( false ) ?;
123105 return p2. read_to_end ( v2) . map ( |_| ( ) ) ;
@@ -127,4 +109,23 @@ pub fn read2(p1: AnonPipe,
127109 return p1. read_to_end ( v1) . map ( |_| ( ) ) ;
128110 }
129111 }
112+
113+ // Read as much as we can from each pipe, ignoring EWOULDBLOCK or
114+ // EAGAIN. If we hit EOF, then this will happen because the underlying
115+ // reader will return Ok(0), in which case we'll see `Ok` ourselves. In
116+ // this case we flip the other fd back into blocking mode and read
117+ // whatever's leftover on that file descriptor.
118+ fn read ( fd : & FileDesc , dst : & mut Vec < u8 > ) -> Result < bool , io:: Error > {
119+ match fd. read_to_end ( dst) {
120+ Ok ( _) => Ok ( true ) ,
121+ Err ( e) => {
122+ if e. raw_os_error ( ) == Some ( libc:: EWOULDBLOCK ) ||
123+ e. raw_os_error ( ) == Some ( libc:: EAGAIN ) {
124+ Ok ( false )
125+ } else {
126+ Err ( e)
127+ }
128+ }
129+ }
130+ }
130131}
0 commit comments