Skip to content

Commit 5e6a8ea

Browse files
committed
rust: Don't call libc::exit
This appears to eliminate the common errors with assertions failures in rust_initialize_rt_tls_key.
1 parent eb55348 commit 5e6a8ea

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/librust/rust.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ extern mod rustc;
2828
use std::io;
2929
use std::os;
3030
use std::run;
31-
use std::libc::exit;
3231

3332
enum ValidUsage {
3433
Valid(int), Invalid
@@ -235,7 +234,7 @@ pub fn main() {
235234

236235
if (os_args.len() > 1 && (os_args[1] == ~"-v" || os_args[1] == ~"--version")) {
237236
rustc::version(os_args[0]);
238-
unsafe { exit(0); }
237+
return;
239238
}
240239

241240
let args = os_args.tail();
@@ -245,8 +244,11 @@ pub fn main() {
245244
for command in r.iter() {
246245
let result = do_command(command, args.tail());
247246
match result {
248-
Valid(exit_code) => unsafe { exit(exit_code.to_i32()) },
249-
_ => loop
247+
Valid(exit_code) => {
248+
os::set_exit_status(exit_code);
249+
return;
250+
}
251+
_ => loop
250252
}
251253
}
252254
}

0 commit comments

Comments
 (0)