Implement tcgetsid using ioctl
This commit is contained in:
@@ -9,7 +9,7 @@ use crate::{
|
||||
},
|
||||
platform::{
|
||||
self,
|
||||
types::{c_int, c_ulong, c_void},
|
||||
types::{c_int, c_ulong, c_void, pid_t},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -85,6 +85,16 @@ pub unsafe extern "C" fn tcsetattr(fd: c_int, act: c_int, value: *const termios)
|
||||
sys_ioctl::ioctl(fd, sys_ioctl::TCSETS + act as c_ulong, value as *mut c_void)
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/009695299/functions/tcgetsid.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn tcgetsid(fd: c_int) -> pid_t {
|
||||
let mut sid = 0;
|
||||
if sys_ioctl::ioctl(fd, sys_ioctl::TIOCGSID, (&raw mut sid) as *mut c_void) < 0 {
|
||||
return -1;
|
||||
}
|
||||
sid
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/cfgetispeed.html>.
|
||||
#[cfg(target_os = "linux")]
|
||||
#[unsafe(no_mangle)]
|
||||
|
||||
Reference in New Issue
Block a user