From b707c378839ec4538fc08a224cd41bf7765d0dd5 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 19 Dec 2025 10:32:56 -0700 Subject: [PATCH] Implement tcgetsid using ioctl --- src/header/termios/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/header/termios/mod.rs b/src/header/termios/mod.rs index 608ecf3555..79624d86ec 100644 --- a/src/header/termios/mod.rs +++ b/src/header/termios/mod.rs @@ -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 . +#[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 . #[cfg(target_os = "linux")] #[unsafe(no_mangle)]