From 0616cba62be78082f10f6673d45ba4d94da423dc Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 12 Jan 2012 22:17:21 -0800 Subject: libcore: Add sys::set_exit_status Sets the process exit code --- src/rt/rust_kernel.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/rt/rust_kernel.cpp') diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index 3078f6b78c4..a7e4ee2e450 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -11,8 +11,8 @@ rust_kernel::rust_kernel(rust_srv *srv, size_t num_threads) : _log(srv, NULL), srv(srv), max_id(0), - num_threads(num_threads), rval(0), + num_threads(num_threads), live_tasks(0), env(srv->env) { @@ -140,6 +140,7 @@ rust_kernel::fail() { // FIXME: On windows we're getting "Application has requested the // Runtime to terminate it in an unusual way" when trying to shutdown // cleanly. + set_exit_status(PROC_FAIL_CODE); #if defined(__WIN32__) exit(rval); #endif @@ -210,6 +211,15 @@ rust_kernel::win32_require(LPCTSTR fn, BOOL ok) { } #endif +void +rust_kernel::set_exit_status(int code) { + scoped_lock with(_kernel_lock); + // If we've already failed then that's the code we're going to use + if (rval != PROC_FAIL_CODE) { + rval = code; + } +} + // // Local Variables: // mode: C++ -- cgit 1.4.1-3-g733a5