diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 35a13471a226b8f1275e4700304fd416820634b3..dd8658e11f21623a7de9498068167b39e31ffe78 100644 --- a/src/header/unistd/mod.rs +++ b/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] diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index 88c40179db52ba4f5fe22e45031a498367531a84..1fd7f722c82687ed447599a213d99e1aa59fa122 100644 --- a/src/platform/linux/mod.rs +++ b/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 } diff --git a/src/platform/pal/mod.rs b/src/platform/pal/mod.rs index 66cae57e81ff9184b0dbc6f6fc0949d93d769133..0aec5db29e485e8f8638dcc9d5ff3cecae996390 100644 --- a/src/platform/pal/mod.rs +++ b/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; diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index 42ef429f58dea97c9164305de6af425f3ce0e37a..de3ac1453a365c89d4724371f6c31b86e68821fb 100644 --- a/src/platform/redox/mod.rs +++ b/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()