From 9e52532f868159486a0f06f8b392e3bdd9263983 Mon Sep 17 00:00:00 2001
From: last-las <478942543@qq.com>
Date: Mon, 4 Apr 2022 10:23:44 +0800
Subject: [PATCH] replace with exit standard codes in somewhere

---
 os/src/trap/mod.rs              | 2 +-
 user/lib/src/bin/10env.rs       | 2 +-
 user/lib/src/bin/10env_child.rs | 1 -
 user/lib/src/panic.rs           | 2 +-
 user/shell/src/main.rs          | 2 +-
 5 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/os/src/trap/mod.rs b/os/src/trap/mod.rs
index 9c7a4e3..19b03d0 100644
--- a/os/src/trap/mod.rs
+++ b/os/src/trap/mod.rs
@@ -33,7 +33,7 @@ pub fn trap_handler() {
         _ => {
             info!("Unsupported trap {:?}, stval = {:#x}, sepc = {:#x}",scause.cause(), stval, sepc);
             match sstatus::read().spp() {
-                sstatus::SPP::User => exit_current_and_run_next_task(4),
+                sstatus::SPP::User => exit_current_and_run_next_task(1),
                 sstatus::SPP::Supervisor => panic!("Supervisor trap!"),
             };
         }
diff --git a/user/lib/src/bin/10env.rs b/user/lib/src/bin/10env.rs
index 910ccfd..d13e78e 100644
--- a/user/lib/src/bin/10env.rs
+++ b/user/lib/src/bin/10env.rs
@@ -28,6 +28,6 @@ fn main() {
         let mut status = 0;
         let ret = waitpid(pid as isize, Some(&mut status), 0).unwrap();
         assert_eq!(ret, pid);
-        assert_eq!(status, 23);
+        assert_eq!(status, 0);
     }
 }
\ No newline at end of file
diff --git a/user/lib/src/bin/10env_child.rs b/user/lib/src/bin/10env_child.rs
index aa2ddd8..3a450d2 100644
--- a/user/lib/src/bin/10env_child.rs
+++ b/user/lib/src/bin/10env_child.rs
@@ -20,5 +20,4 @@ fn main() {
     }
 
     println!("\nargs: {:#?}", get_args());
-    exit(23);
 }
\ No newline at end of file
diff --git a/user/lib/src/panic.rs b/user/lib/src/panic.rs
index b2b2a0a..d1bb942 100644
--- a/user/lib/src/panic.rs
+++ b/user/lib/src/panic.rs
@@ -8,7 +8,7 @@ fn panic(panic_info: &PanicInfo) -> ! {
     } else {
         println!("Panicked: {}", panic_info.message().unwrap());
     }
-    exit(4);
+    exit(1);
     // This loop should never be reached.
     loop{}
 }
\ No newline at end of file
diff --git a/user/shell/src/main.rs b/user/shell/src/main.rs
index 90d8667..0082b44 100644
--- a/user/shell/src/main.rs
+++ b/user/shell/src/main.rs
@@ -22,7 +22,7 @@ fn main() {
         if ret == 0 {
             if exec(line.as_str(), vec![line.as_str()]).is_err() {
                 println!("{}: no such file", line);
-                exit(4);
+                exit(127);
             }
         } else {
             let pid = waitpid(ret as isize, None, 0).unwrap();
-- 
GitLab