@@ -23,9 +23,7 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
23
23
24
24
libc:: pipe2 ( & mut fds, libc:: O_CLOEXEC ) . map_err ( |err| io:: Error :: from_raw_os_error ( err. errno ) ) ?;
25
25
26
- let fd0 = FileDesc :: new ( fds[ 0 ] ) ;
27
- let fd1 = FileDesc :: new ( fds[ 1 ] ) ;
28
- Ok ( ( AnonPipe :: from_fd ( fd0) ?, AnonPipe :: from_fd ( fd1) ?) )
26
+ Ok ( ( AnonPipe ( FileDesc :: new ( fds[ 0 ] ) ) , AnonPipe ( FileDesc :: new ( fds[ 1 ] ) ) ) )
29
27
}
30
28
31
29
impl AnonPipe {
@@ -50,12 +48,18 @@ impl AnonPipe {
50
48
pub fn into_fd ( self ) -> FileDesc { self . 0 }
51
49
}
52
50
53
- pub fn read2 ( _p1 : AnonPipe ,
54
- _v1 : & mut Vec < u8 > ,
55
- _p2 : AnonPipe ,
56
- _v2 : & mut Vec < u8 > ) -> io:: Result < ( ) > {
57
- :: sys_common:: util:: dumb_print ( format_args ! ( "read2\n " ) ) ;
58
- unimplemented ! ( ) ;
51
+ pub fn read2 ( p1 : AnonPipe ,
52
+ v1 : & mut Vec < u8 > ,
53
+ p2 : AnonPipe ,
54
+ v2 : & mut Vec < u8 > ) -> io:: Result < ( ) > {
55
+ //TODO: Use event based I/O multiplexing
56
+ //unimplemented!()
57
+
58
+ p1. read_to_end ( v1) ?;
59
+ p2. read_to_end ( v2) ?;
60
+
61
+ Ok ( ( ) )
62
+
59
63
/*
60
64
// Set both pipes into nonblocking mode as we're gonna be reading from both
61
65
// in the `select` loop below, and we wouldn't want one to block the other!
@@ -64,7 +68,6 @@ pub fn read2(_p1: AnonPipe,
64
68
p1.set_nonblocking(true)?;
65
69
p2.set_nonblocking(true)?;
66
70
67
- let max = cmp::max(p1.raw(), p2.raw());
68
71
loop {
69
72
// wait for either pipe to become readable using `select`
70
73
cvt_r(|| unsafe {
0 commit comments