Skip to main content

atomcode_core/
process_utils.rs

1//! Platform-specific process utilities.
2//!
3//! On Windows, GUI processes (like VSCode extension host / atomcode-daemon)
4//! that spawn console programs (git, curl, cmd.exe, etc.) will cause Windows
5//! to automatically create a visible console window for the child process.
6//! The `suppress_console_window` helpers apply the `CREATE_NO_WINDOW` creation
7//! flag to prevent this.
8
9/// Apply `CREATE_NO_WINDOW` to a `tokio::process::Command` on Windows.
10/// No-op on other platforms.
11#[cfg(target_os = "windows")]
12pub fn suppress_console_window(cmd: &mut tokio::process::Command) {
13    use std::os::windows::process::CommandExt;
14    const CREATE_NO_WINDOW: u32 = 0x08000000;
15    cmd.creation_flags(CREATE_NO_WINDOW);
16}
17
18/// No-op on non-Windows platforms.
19#[cfg(not(target_os = "windows"))]
20pub fn suppress_console_window(_cmd: &mut tokio::process::Command) {}
21
22/// Apply `CREATE_NO_WINDOW` to a `std::process::Command` on Windows.
23/// No-op on other platforms.
24#[cfg(target_os = "windows")]
25pub fn suppress_console_window_sync(cmd: &mut std::process::Command) {
26    use std::os::windows::process::CommandExt;
27    const CREATE_NO_WINDOW: u32 = 0x08000000;
28    cmd.creation_flags(CREATE_NO_WINDOW);
29}
30
31/// No-op on non-Windows platforms.
32#[cfg(not(target_os = "windows"))]
33pub fn suppress_console_window_sync(_cmd: &mut std::process::Command) {}