about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-08-07 19:38:18 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-08-07 20:19:18 -0700
commitd9038fc3b3222c678bdf2d06b896322976eaacf5 (patch)
tree84abc2ce29f0ab8cb6c55648e78c33972b678b19 /src
parent8888d7c8e93288cf2e07198930cc9f2ae2dc6022 (diff)
downloadrust-d9038fc3b3222c678bdf2d06b896322976eaacf5.tar.gz
rust-d9038fc3b3222c678bdf2d06b896322976eaacf5.zip
rustdoc: Set a nonzero exit status on failure
Now that rustdoc is spawning a child task, the program won't exit with a default
error code if the main task fails (because it never fails). This commit forces
the main task to wait for a child task in order to correctly propagate failure.

Closes #16341
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/lib.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index fb974403858..6c254b62177 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -120,9 +120,16 @@ pub fn main() {
     // So, in summary, it is unknown why this is necessary, what it is
     // preventing, or what the actual bug is. In the meantime, this allows
     // --test to work on windows, which seems good, right? Fun times.
+    let (tx, rx) = channel();
     spawn(proc() {
         std::os::set_exit_status(main_args(std::os::args().as_slice()));
+        tx.send(());
     });
+
+    // If the task failed, set an error'd exit status
+    if rx.recv_opt().is_err() {
+        std::os::set_exit_status(std::rt::DEFAULT_ERROR_CODE);
+    }
 }
 
 pub fn opts() -> Vec<getopts::OptGroup> {