(domain: &str, label: &str)
| 500 | } |
| 501 | |
| 502 | fn launchagent_pid(domain: &str, label: &str) -> Option<u32> { |
| 503 | let target = format!("{domain}/{label}"); |
| 504 | let output = Command::new("launchctl") |
| 505 | .args(["print", &target]) |
| 506 | .output() |
| 507 | .ok()?; |
| 508 | if !output.status.success() { |
| 509 | return None; |
| 510 | } |
| 511 | let stdout = String::from_utf8_lossy(&output.stdout); |
| 512 | stdout.lines().find_map(parse_launchctl_pid) |
| 513 | } |
| 514 | |
| 515 | fn parse_launchctl_pid(line: &str) -> Option<u32> { |
| 516 | line.trim().strip_prefix("pid = ")?.trim().parse().ok() |
no test coverage detected