diff --git a/src/platform/macos.rs b/src/platform/macos.rs index 0bfef0e5b..777071dc0 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -145,7 +145,7 @@ pub fn is_installed_daemon(prompt: bool) -> bool { .args(&["load", "-w", &agent_plist_file]) .status() .ok(); - std::process::exit(0); + quit_gui(); } } } @@ -183,6 +183,8 @@ pub fn uninstall() -> bool { ); if uninstalled { crate::ipc::set_option("stop-service", "Y"); + // leave ipc a little time + std::thread::sleep(std::time::Duration::from_millis(300)); std::process::Command::new("launchctl") .args(&["remove", &format!("{}_server", crate::get_full_name())]) .status() @@ -202,7 +204,7 @@ pub fn uninstall() -> bool { )) .spawn() .ok(); - std::process::exit(0); + quit_gui(); } } } @@ -517,3 +519,10 @@ pub fn is_installed() -> bool { } false } + +fn quit_gui() { + use cocoa::appkit::NSApp; + unsafe { + let () = msg_send!(NSApp(), terminate: nil); + }; +} diff --git a/src/server.rs b/src/server.rs index 9cc783208..3b370dc5f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -339,7 +339,7 @@ async fn sync_and_watch_config_dir() { if std::env::args().len() == 2 && std::env::args().nth(1) == Some("--server".to_owned()) { 30 } else { - 1 + 3 }; log::debug!("#tries of ipc service connection: {}", tries); for i in 1..=tries {