Skip to content

Commit

Permalink
pass 'CREATE_NO_WINDOW' flag to child process on windows (#14)
Browse files Browse the repository at this point in the history
Co-authored-by: Automated Release Test <release-tests-no-reply@zfnd.org>
  • Loading branch information
arya2 and Automated Release Test authored Mar 8, 2024
1 parent ec44d1b commit 9b3570c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src-tauri/src/child_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@ use tokio::sync::{mpsc::Receiver, oneshot};
/// Zebrad Configuration Filename
pub const CONFIG_FILE: &str = "zebrad.toml";

/// > The process is a console application that is being run without a console window.
/// > Therefore, the console handle for the application is not set.
/// > This flag is ignored if the application is not a console application, or
/// > if it is used with either CREATE_NEW_CONSOLE or DETACHED_PROCESS.
/// See <https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags>
#[cfg(windows)]
const CREATE_NO_WINDOW: u32 = 0x08000000;

#[cfg(windows)]
pub const ZEBRAD_COMMAND_NAME: &str = "zebrad.exe";

#[cfg(windows)]
use std::os::windows::process::CommandExt;

#[cfg(not(windows))]
pub const ZEBRAD_COMMAND_NAME: &str = "zebrad";

Expand Down Expand Up @@ -64,10 +75,17 @@ pub fn run_zebrad() -> (Child, Receiver<String>, oneshot::Sender<()>) {
);
}

let mut zebrad_child = Command::new(zebrad_path_str)
let mut zebrad_child = Command::new(zebrad_path_str);

zebrad_child
.args(["-c", &zebrad_config_path_str])
.stderr(Stdio::piped())
.stdout(Stdio::piped())
.stdout(Stdio::piped());

#[cfg(windows)]
zebrad_child.creation_flags(CREATE_NO_WINDOW);

let mut zebrad_child = zebrad_child
.spawn()
.expect("zebrad should be installed as a bundled binary and should start successfully");

Expand Down

0 comments on commit 9b3570c

Please sign in to comment.