| 517 | } |
| 518 | |
| 519 | fn run_launchctl<const N: usize>(args: [&str; N]) -> anyhow::Result<()> { |
| 520 | let output = Command::new("launchctl") |
| 521 | .args(args) |
| 522 | .output() |
| 523 | .context("run launchctl")?; |
| 524 | if output.status.success() { |
| 525 | return Ok(()); |
| 526 | } |
| 527 | |
| 528 | let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string(); |
| 529 | bail!( |
| 530 | "launchctl {} failed: {}", |
| 531 | args.join(" "), |
| 532 | if stderr.is_empty() { |
| 533 | "unknown error" |
| 534 | } else { |
| 535 | &stderr |
| 536 | } |
| 537 | ); |
| 538 | } |
| 539 | |
| 540 | fn terminate_process_group(pid: u32, timeout: Duration) { |
| 541 | signal_process_group(pid, "TERM"); |