aboutsummaryrefslogtreecommitdiff
path: root/src/platform/macos.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/macos.rs')
-rw-r--r--src/platform/macos.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/platform/macos.rs b/src/platform/macos.rs
index ac0e160b..e38b29eb 100644
--- a/src/platform/macos.rs
+++ b/src/platform/macos.rs
@@ -1,5 +1,6 @@
use std::ffi::OsStr;
use std::io::Write;
+use std::os::fd::RawFd;
use std::os::unix::ffi::OsStrExt;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
@@ -177,6 +178,11 @@ pub fn foreground_process_group_id(pid: u32) -> Option<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)
+}
+
/// Get the effective process name from `argv[0]` via `sysctl(KERN_PROCARGS2)`.
///
/// This is the macOS equivalent of reading `/proc/{pid}/cmdline` on Linux.