libcore: Add sys::set_exit_status

Sets the process exit code
This commit is contained in:
Brian Anderson
2012-01-12 22:17:21 -08:00
parent dcac427795
commit 0616cba62b
10 changed files with 68 additions and 5 deletions

View File

@@ -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++