+struct Pipe {
+ pipe_fd: [i32; 2],
+}
+
+impl Pipe {
+ fn new() -> Pipe {
+ let mut pipe_fd = [-1i32; 2];
+
+ unsafe {
+ extern {
+ fn pipe(pipefd: *mut i32) -> i32;
+ }
+
+ pipe(pipe_fd.as_mut_ptr());
+ }
+
+ Pipe {
+ pipe_fd: pipe_fd,
+ }
+ }
+
+ fn read_fd(&self) -> i32 {
+ self.pipe_fd[0]
+ }
+
+ fn write_fd(&self) -> i32 {
+ self.pipe_fd[1]
+ }
+}
+