MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / unload_existing_services

Function unload_existing_services

packages/server/src/service.rs:480–500  ·  view source on GitHub ↗
(domain: &str)

Source from the content-addressed store, hash-verified

478}
479
480fn unload_existing_services(domain: &str) -> anyhow::Result<Vec<u32>> {
481 let mut killed = Vec::new();
482 for label in service_labels() {
483 let plist_path = plist_path_for_label(label)?;
484 let old_pid = launchagent_pid(domain, label);
485 let service_target = format!("{domain}/{label}");
486 let _ = Command::new("launchctl")
487 .args(["bootout", &service_target])
488 .output();
489 if plist_path.exists() {
490 let _ = Command::new("launchctl")
491 .args(["bootout", domain, plist_path.to_string_lossy().as_ref()])
492 .output();
493 }
494 if let Some(pid) = old_pid {
495 terminate_process_group(pid, SERVICE_SHUTDOWN_GRACE);
496 killed.push(pid);
497 }
498 }
499 Ok(killed)
500}
501
502fn launchagent_pid(domain: &str, label: &str) -> Option<u32> {
503 let target = format!("{domain}/{label}");

Callers 2

installFunction · 0.85
kill_installedFunction · 0.85

Calls 5

service_labelsFunction · 0.85
plist_path_for_labelFunction · 0.85
launchagent_pidFunction · 0.85
terminate_process_groupFunction · 0.70
outputMethod · 0.65

Tested by

no test coverage detected