about summary refs log tree commit diff
path: root/src/libstd/run.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-12-04 15:20:26 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-12-10 15:13:12 -0800
commitec5603bf13ccb95c311fe5ca193a32efe07147a2 (patch)
tree6cf2f33e901d673ba63fa781ddb5167beaae42f8 /src/libstd/run.rs
parentab3bec91d77150e434ac1480fbb3935213e33dca (diff)
downloadrust-ec5603bf13ccb95c311fe5ca193a32efe07147a2.tar.gz
rust-ec5603bf13ccb95c311fe5ca193a32efe07147a2.zip
librustpkg: Make `io::ignore_io_error()` use RAII; remove a few more
cells.
Diffstat (limited to 'src/libstd/run.rs')
-rw-r--r--src/libstd/run.rs29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/libstd/run.rs b/src/libstd/run.rs
index 2447bba98d6..f4c6cdbd934 100644
--- a/src/libstd/run.rs
+++ b/src/libstd/run.rs
@@ -12,7 +12,6 @@
 
 #[allow(missing_doc)];
 
-use cell::Cell;
 use comm::{stream, SharedChan};
 use io::Reader;
 use io::process::ProcessExit;
@@ -212,8 +211,8 @@ impl Process {
      */
     pub fn finish_with_output(&mut self) -> ProcessOutput {
         self.close_input();
-        let output = Cell::new(self.inner.io[1].take());
-        let error = Cell::new(self.inner.io[2].take());
+        let output = self.inner.io[1].take();
+        let error = self.inner.io[2].take();
 
         // Spawn two entire schedulers to read both stdout and sterr
         // in parallel so we don't deadlock while blocking on one
@@ -224,20 +223,20 @@ impl Process {
         let ch_clone = ch.clone();
 
         do spawn {
-            io::ignore_io_error(|| {
-                match error.take() {
-                    Some(ref mut e) => ch.send((2, e.read_to_end())),
-                    None => ch.send((2, ~[]))
-                }
-            })
+            let _guard = io::ignore_io_error();
+            let mut error = error;
+            match error {
+                Some(ref mut e) => ch.send((2, e.read_to_end())),
+                None => ch.send((2, ~[]))
+            }
         }
         do spawn {
-            io::ignore_io_error(|| {
-                match output.take() {
-                    Some(ref mut e) => ch_clone.send((1, e.read_to_end())),
-                    None => ch_clone.send((1, ~[]))
-                }
-            })
+            let _guard = io::ignore_io_error();
+            let mut output = output;
+            match output {
+                Some(ref mut e) => ch_clone.send((1, e.read_to_end())),
+                None => ch_clone.send((1, ~[]))
+            }
         }
 
         let status = self.finish();