diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-26 14:40:36 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-26 14:44:22 +0300 |
| commit | 9eec3029e13b791b8a4954e38d5bb7db6e2ff68f (patch) | |
| tree | 83825b0a824dc3cd0d951140064feec457a38174 /src/platform/linux.rs | |
| parent | 62b9795771b22e36b1464c235745990eaa8921e6 (diff) | |
fix: reduce idle agent checker CPU
refs #300
Diffstat (limited to 'src/platform/linux.rs')
| -rw-r--r-- | src/platform/linux.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 73a4f0a5..00f4b906 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -54,6 +54,25 @@ pub fn foreground_job(child_pid: u32) -> Option<ForegroundJob> { }) } +pub fn foreground_group_leader_job(process_group_id: u32) -> Option<ForegroundJob> { + let (pgrp, name) = process_pgrp_and_comm(process_group_id)?; + if pgrp as u32 != process_group_id { + return None; + } + + let argv = process_argv(process_group_id); + Some(ForegroundJob { + process_group_id, + processes: vec![ForegroundProcess { + pid: process_group_id, + name, + argv0: None, + cmdline: argv.as_ref().map(|parts| parts.join(" ")), + argv, + }], + }) +} + pub fn foreground_process_group_id(child_pid: u32) -> Option<u32> { // /proc/<pid>/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. |
