Browse Source

Fix waitpid -1 on redox

jD91mZM2 6 years ago
parent
commit
d39a66c351
2 changed files with 7 additions and 2 deletions
  1. 3 1
      src/platform/src/linux/mod.rs
  2. 4 1
      src/platform/src/redox/mod.rs

+ 3 - 1
src/platform/src/linux/mod.rs

@@ -5,6 +5,8 @@ use types::*;
 
 const EINVAL: c_int = 22;
 
+const SIGCHLD: usize = 17;
+
 const TCGETS: c_ulong = 0x5401;
 const TCSETS: c_ulong = 0x5402;
 const TIOCGWINSZ: c_ulong = 0x5413;
@@ -106,7 +108,7 @@ pub fn fcntl(fildes: c_int, cmd: c_int, arg: c_int) -> c_int {
 }
 
 pub fn fork() -> pid_t {
-    e(unsafe { syscall!(CLONE, 17, 0) }) as pid_t
+    e(unsafe { syscall!(CLONE, SIGCHLD, 0) }) as pid_t
 }
 
 pub fn fsync(fildes: c_int) -> c_int {

+ 4 - 1
src/platform/src/redox/mod.rs

@@ -1045,7 +1045,10 @@ pub fn unlink(path: *const c_char) -> c_int {
     e(syscall::unlink(path)) as c_int
 }
 
-pub fn waitpid(pid: pid_t, stat_loc: *mut c_int, options: c_int) -> pid_t {
+pub fn waitpid(mut pid: pid_t, stat_loc: *mut c_int, options: c_int) -> pid_t {
+    if pid == !0 {
+        pid = 0;
+    }
     unsafe {
         let mut temp: usize = 0;
         let res = e(syscall::waitpid(pid as usize, &mut temp, options as usize));