diff options
Diffstat (limited to 'src/platform/linux.rs')
| -rw-r--r-- | src/platform/linux.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 046e72c7..d1ae07f1 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -1,5 +1,6 @@ use std::{ io::Write, + os::fd::RawFd, path::PathBuf, process::{Command, Stdio}, }; @@ -86,6 +87,11 @@ pub fn foreground_process_group_id(child_pid: u32) -> Option<u32> { (tpgid > 0).then_some(tpgid as u32) } +pub fn foreground_process_group_id_for_tty_fd(fd: RawFd) -> Option<u32> { + let pgid = unsafe { libc::tcgetpgrp(fd) }; + (pgid > 0).then_some(pgid as u32) +} + fn process_pgrp_and_comm(pid: u32) -> Option<(i32, String)> { let stat = std::fs::read_to_string(format!("/proc/{pid}/stat")).ok()?; let close = stat.rfind(')')?; |
