Browse Source

Add getsid stub

Jeremy Soller 2 years ago
parent
commit
b30c33adc3
4 changed files with 15 additions and 3 deletions
  1. 2 2
      src/header/unistd/mod.rs
  2. 4 0
      src/platform/linux/mod.rs
  3. 2 0
      src/platform/pal/mod.rs
  4. 7 1
      src/platform/redox/mod.rs

+ 2 - 2
src/header/unistd/mod.rs

@@ -402,9 +402,9 @@ pub extern "C" fn getppid() -> pid_t {
     Sys::getppid()
 }
 
-// #[no_mangle]
+#[no_mangle]
 pub extern "C" fn getsid(pid: pid_t) -> pid_t {
-    unimplemented!();
+    Sys::getsid(pid)
 }
 
 #[no_mangle]

+ 4 - 0
src/platform/linux/mod.rs

@@ -267,6 +267,10 @@ impl Pal for Sys {
         e(syscall!(GETRLIMIT, resource, rlim)) as c_int
     }
 
+    fn getsid(pid: pid_t) -> pid_t {
+        e(unsafe { syscall!(GETSID, pid) }) as pid_t
+    }
+
     fn gettid() -> pid_t {
         e(unsafe { syscall!(GETTID) }) as pid_t
     }

+ 2 - 0
src/platform/pal/mod.rs

@@ -100,6 +100,8 @@ pub trait Pal {
 
     unsafe fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int;
 
+    fn getsid(pid: pid_t) -> pid_t;
+
     fn gettid() -> pid_t;
 
     fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int;

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

@@ -13,7 +13,7 @@ use crate::{
     fs::File,
     header::{
         dirent::dirent,
-        errno::{EINVAL, EIO, ENOMEM, EPERM, ERANGE},
+        errno::{EINVAL, EIO, ENOMEM, ENOSYS, EPERM, ERANGE},
         fcntl,
         string::strlen,
         sys_mman::{MAP_ANONYMOUS, PROT_READ, PROT_WRITE},
@@ -533,6 +533,12 @@ impl Pal for Sys {
         0
     }
 
+    fn getsid(pid: pid_t) -> pid_t {
+        //TODO
+        unsafe { errno = ENOSYS };
+        -1
+    }
+
     fn gettid() -> pid_t {
         //TODO
         Self::getpid()