From 94b90043f98499a1ed3594dd9ea42b2aef62b93a Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Wed, 6 May 2026 20:17:52 +0300 Subject: fix: clear native agent detection after shell returns fixes #66 --- src/platform/linux.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/platform/linux.rs') diff --git a/src/platform/linux.rs b/src/platform/linux.rs index dc944cd9..13aa6ec8 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -8,7 +8,7 @@ use super::{ClipboardCommand, ForegroundJob, ForegroundProcess, Signal}; /// Collect the foreground terminal job for a given child PID. pub fn foreground_job(child_pid: u32) -> Option { - let tpgid = foreground_pgid(child_pid)? as u32; + let tpgid = foreground_process_group_id(child_pid)?; let mut processes = Vec::new(); for entry in std::fs::read_dir("/proc").ok()? { @@ -49,7 +49,7 @@ pub fn foreground_job(child_pid: u32) -> Option { }) } -fn foreground_pgid(child_pid: u32) -> Option { +pub fn foreground_process_group_id(child_pid: u32) -> Option { // /proc//stat format: "pid (comm) state ppid pgrp session tty_nr tpgid ..." // The (comm) field can contain spaces and parens, so we find the last ')' first. let stat = std::fs::read_to_string(format!("/proc/{child_pid}/stat")).ok()?; @@ -57,7 +57,7 @@ fn foreground_pgid(child_pid: u32) -> Option { let fields: Vec<&str> = rest.split_whitespace().collect(); // After (comm): state(0) ppid(1) pgrp(2) session(3) tty_nr(4) tpgid(5) let tpgid: i32 = fields.get(5)?.parse().ok()?; - (tpgid > 0).then_some(tpgid) + (tpgid > 0).then_some(tpgid as u32) } fn process_pgrp_and_comm(pid: u32) -> Option<(i32, String)> { -- cgit v1.2.3