Browse Source

修复了wait4的异常报错 (#312)

* 修复了wait4的异常报错
Chiichen 1 year ago
parent
commit
4da3758acf
2 changed files with 9 additions and 2 deletions
  1. 3 2
      kernel/src/process/syscall.rs
  2. 6 0
      user/libs/libc/src/include/export/unistd.h

+ 3 - 2
kernel/src/process/syscall.rs

@@ -41,8 +41,9 @@ impl Syscall {
     ) -> Result<usize, SystemError> {
         let ret = unsafe { c_sys_wait4(pid, wstatus, options, rusage) };
         if (ret as isize) < 0 {
-            return Err(SystemError::from_posix_errno(-(ret as isize) as i32)
-                .expect("wait4: Invalid errno"));
+            return Err(
+                SystemError::from_posix_errno((ret as isize) as i32).expect("wait4: Invalid errno")
+            );
         }
         return Ok(ret as usize);
     }

+ 6 - 0
user/libs/libc/src/include/export/unistd.h

@@ -120,6 +120,12 @@ int rm(const char * path);
  */
 void swab(void *restrict src, void *restrict dest, ssize_t nbytes);
 
+/**
+ * @brief   创建pipe
+ *  @param fildes  分别是读端fildes[0]和写端fildes[1]
+ */
+int pipe(int fildes[2]);
+
 pid_t getpid(void);
 
 int dup(int fd);