aboutsummaryrefslogtreecommitdiff
path: root/src/platform
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-29 20:38:55 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-29 20:38:55 +0300
commit9e302984ccb13a65e3e504fa7692b223f546ff84 (patch)
tree52808a27bd82c05f55117ad129137fe3ef46a8cb /src/platform
parent77242943ba65a80cbc1180258dd64f06635233f9 (diff)
feat: expose foreground cwd in pane info
refs #345
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/linux.rs6
-rw-r--r--src/platform/macos.rs6
2 files changed, 12 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(')')?;
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.