From b0f3743ae043fc319d2b396af34e5290f716e90e Mon Sep 17 00:00:00 2001 From: Cherry <13651622+MolotovCherry@users.noreply.github.com> Date: Tue, 3 Sep 2024 23:09:03 -0700 Subject: [PATCH] Properly detach daemon on windows in `-d` mode --- pueue/src/bin/pueued.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pueue/src/bin/pueued.rs b/pueue/src/bin/pueued.rs index c7448e6e..e7a199ec 100644 --- a/pueue/src/bin/pueued.rs +++ b/pueue/src/bin/pueued.rs @@ -125,7 +125,17 @@ fn fork_daemon(opt: &CliArguments) -> Result<()> { "pueued".to_string() }; - Command::new(current_exe) + let mut command = Command::new(current_exe); + + #[cfg(target_os = "windows")] + { + use std::os::windows::process::CommandExt; + const CREATE_NO_WINDOW: u32 = 0x08000000; + + command.creation_flags(CREATE_NO_WINDOW); + } + + command .args(&arguments) .spawn() .expect("Failed to fork new process.");