Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0616cba6
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0616cba6
编写于
1月 12, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libcore: Add sys::set_exit_status
Sets the process exit code
上级
dcac4277
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
68 addition
and
5 deletion
+68
-5
src/libcore/sys.rs
src/libcore/sys.rs
+13
-0
src/rt/rust_builtin.cpp
src/rt/rust_builtin.cpp
+6
-0
src/rt/rust_internal.h
src/rt/rust_internal.h
+1
-1
src/rt/rust_kernel.cpp
src/rt/rust_kernel.cpp
+11
-1
src/rt/rust_kernel.h
src/rt/rust_kernel.h
+3
-1
src/rt/rust_scheduler.cpp
src/rt/rust_scheduler.cpp
+0
-2
src/rt/rustrt.def.in
src/rt/rustrt.def.in
+1
-0
src/test/run-fail/rt-set-exit-status-fail.rs
src/test/run-fail/rt-set-exit-status-fail.rs
+10
-0
src/test/run-fail/rt-set-exit-status-fail2.rs
src/test/run-fail/rt-set-exit-status-fail2.rs
+15
-0
src/test/run-fail/rt-set-exit-status.rs
src/test/run-fail/rt-set-exit-status.rs
+8
-0
未找到文件。
src/libcore/sys.rs
浏览文件 @
0616cba6
...
...
@@ -20,6 +20,7 @@
fn
do_gc
();
fn
unsupervise
();
fn
shape_log_str
<
T
>
(
t
:
*
sys
::
type_desc
,
data
:
T
)
->
str
;
fn
rust_set_exit_status
(
code
:
int
);
}
#[abi
=
"rust-intrinsic"
]
...
...
@@ -92,6 +93,18 @@ fn log_str<T>(t: T) -> str {
rustrt
::
shape_log_str
(
get_type_desc
::
<
T
>
(),
t
)
}
#[doc(
brief
=
"Sets the process exit code"
,
desc
=
"Sets the exit code returned by the process if all supervised
\
tasks terminate successfully (without failing). If the current
\
root task fails and is supervised by the scheduler then any
\
user-specified exit status is ignored and the process exits
\
with the default failure status."
)]
fn
set_exit_status
(
code
:
int
)
{
rustrt
::
rust_set_exit_status
(
code
);
}
// Local Variables:
// mode: rust;
// fill-column: 78;
...
...
src/rt/rust_builtin.cpp
浏览文件 @
0616cba6
...
...
@@ -561,6 +561,12 @@ port_recv(uintptr_t *dptr, rust_port *port,
return
;
}
extern
"C"
CDECL
void
rust_set_exit_status
(
intptr_t
code
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
task
->
kernel
->
set_exit_status
((
int
)
code
);
}
//
// Local Variables:
// mode: C++
...
...
src/rt/rust_internal.h
浏览文件 @
0616cba6
...
...
@@ -92,7 +92,7 @@ static size_t const TIME_SLICE_IN_MS = 10;
static
size_t
const
BUF_BYTES
=
2048
;
// The error status to use when the process fails
#define PROC_FAIL_CODE 101
;
#define PROC_FAIL_CODE 101
// Every reference counted object should use this macro and initialize
// ref_count.
...
...
src/rt/rust_kernel.cpp
浏览文件 @
0616cba6
...
...
@@ -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++
...
...
src/rt/rust_kernel.h
浏览文件 @
0616cba6
...
...
@@ -34,9 +34,10 @@ private:
rust_task_id
max_id
;
hash_map
<
rust_task_id
,
rust_task
*>
task_table
;
int
rval
;
public:
const
size_t
num_threads
;
int
rval
;
volatile
int
live_tasks
;
struct
rust_env
*
env
;
...
...
@@ -68,6 +69,7 @@ public:
rust_task_id
create_task
(
rust_task
*
spawner
,
const
char
*
name
);
rust_task
*
get_task_by_id
(
rust_task_id
id
);
void
release_task_id
(
rust_task_id
tid
);
void
set_exit_status
(
int
code
);
};
#endif
/* RUST_KERNEL_H */
src/rt/rust_scheduler.cpp
浏览文件 @
0616cba6
...
...
@@ -82,8 +82,6 @@ void
rust_scheduler
::
fail
()
{
log
(
NULL
,
log_err
,
"domain %s @0x%"
PRIxPTR
" root task failed"
,
name
,
this
);
I
(
this
,
kernel
->
rval
==
0
);
kernel
->
rval
=
PROC_FAIL_CODE
;
kernel
->
fail
();
}
...
...
src/rt/rustrt.def.in
浏览文件 @
0616cba6
...
...
@@ -41,6 +41,7 @@ rust_port_size
rust_process_wait
rust_ptr_eq
rust_run_program
rust_set_exit_status
rust_start
rust_getcwd
rust_task_is_unwinding
...
...
src/test/run-fail/rt-set-exit-status-fail.rs
0 → 100644
浏览文件 @
0616cba6
// error-pattern:whatever
fn
main
()
{
log
(
error
,
"whatever"
);
// Setting the exit status only works when the scheduler terminates
// normally. In this case we're going to fail, so instead of of
// returning 50 the process will return the typical rt failure code.
sys
::
set_exit_status
(
50
);
fail
;
}
\ No newline at end of file
src/test/run-fail/rt-set-exit-status-fail2.rs
0 → 100644
浏览文件 @
0616cba6
// error-pattern:whatever
fn
main
()
{
log
(
error
,
"whatever"
);
task
::
spawn
{||
resource
r
(
_
i
:
())
{
// Setting the exit status after the runtime has already
// failed has no effect and the process exits with the
// runtime's exit code
sys
::
set_exit_status
(
50
);
}
let
i
=
r
(());
};
fail
;
}
\ No newline at end of file
src/test/run-fail/rt-set-exit-status.rs
0 → 100644
浏览文件 @
0616cba6
// error-pattern:whatever
fn
main
()
{
log
(
error
,
"whatever"
);
// 101 is the code the runtime uses on task failure and the value
// compiletest expects run-fail tests to return.
sys
::
set_exit_status
(
101
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录