Skip to content

Commit

Permalink
Set CREATE_NO_WINDOW for daemon start on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pka committed Oct 11, 2024
1 parent e8fc272 commit 0bb7e4d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/bin/shell_compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,20 @@ impl DispatcherProc {
.replace("compose", "composed"),
);
let mut proc = process::Command::new(exe);
let proc = if env::var("RUST_LOG").unwrap_or("".to_string()) == "debug" {
#[cfg(target_os = "windows")]
{
use std::os::windows::process::CommandExt;
const CREATE_NO_WINDOW: u32 = 0x08000000;
// CREATE_NO_WINDOW causes all children to not show a visible console window,
// but it also apparently has the effect of starting a new process group.
//
// https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags#flags
// https://stackoverflow.com/a/71364777/9423933
proc.creation_flags(CREATE_NO_WINDOW);

// See https://stackoverflow.com/a/78989930 for a possible alternative.
}
if env::var("RUST_LOG").unwrap_or("".to_string()) == "debug" {
proc.env("RUST_LOG", "debug")
} else {
proc.stdout(Stdio::null()).stderr(Stdio::null())
Expand Down

0 comments on commit 0bb7e4d

Please sign in to comment.