about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-01-04 12:21:46 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-01-05 09:20:31 -0800
commiteadfe0e3c9b55ec48637d5cdae36eca7421a8159 (patch)
treee24dbf2474ff0fe6d1bce1708e127bc21747a925 /src/libnative
parent4eceb0050c107c4ed18221bde9e5046613a710b6 (diff)
downloadrust-eadfe0e3c9b55ec48637d5cdae36eca7421a8159.tar.gz
rust-eadfe0e3c9b55ec48637d5cdae36eca7421a8159.zip
Don't abort the process in native::start
If the main closure failed, then the `exit_code` variable would still be `None`,
and the `unwrap()` was failing (triggering a process abort). This changes the
`unwrap()` to an `unwrap_or()` in order to prevent process abort and detect when
the native task failed.
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/lib.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs
index b3b83fda599..9c30e94194d 100644
--- a/src/libnative/lib.rs
+++ b/src/libnative/lib.rs
@@ -73,7 +73,8 @@ pub fn start(argc: int, argv: **u8, main: proc()) -> int {
         exit_code = Some(run(main.take_unwrap()));
     });
     unsafe { rt::cleanup(); }
-    return exit_code.unwrap();
+    // If the exit code wasn't set, then the task block must have failed.
+    return exit_code.unwrap_or(rt::DEFAULT_ERROR_CODE);
 }
 
 /// Executes a procedure on the current thread in a Rust task context.