Avoid panicking when inputting error app name; List all apps when initializing.
This commit is contained in:
parent
8fbadfc951
commit
d0af7d26be
4 changed files with 19 additions and 6 deletions
|
@ -51,3 +51,12 @@ fn app_names() -> Vec<&'static str> {
|
|||
}
|
||||
v
|
||||
}
|
||||
|
||||
pub fn list_apps() {
|
||||
let apps = app_names();
|
||||
println!("/**** APPS ****");
|
||||
for app in apps {
|
||||
println!("{}", app);
|
||||
}
|
||||
println!("**************/")
|
||||
}
|
|
@ -46,6 +46,7 @@ pub fn rust_main() -> ! {
|
|||
trap::init();
|
||||
trap::enable_timer_interrupt();
|
||||
timer::set_next_trigger();
|
||||
loader::list_apps();
|
||||
task::run_tasks();
|
||||
panic!("Unreachable in rust_main!");
|
||||
}
|
|
@ -59,10 +59,13 @@ pub fn sys_fork() -> isize {
|
|||
pub fn sys_exec(path: *const u8) -> isize {
|
||||
let token = current_user_token();
|
||||
let path = translated_str(token, path);
|
||||
let data = get_app_data_by_name(path.as_str()).unwrap();
|
||||
let task = current_task().unwrap();
|
||||
task.exec(data);
|
||||
0
|
||||
if let Some(data) = get_app_data_by_name(path.as_str()) {
|
||||
let task = current_task().unwrap();
|
||||
task.exec(data);
|
||||
0
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sys_waitpid(pid: isize, exit_code_ptr: *mut i32) -> isize {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue