Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a67b1cd

Browse filesBrowse files
committed
fix: set CREATE_NO_WINDOW creation flag on Windows
1 parent 5423e5c commit a67b1cd
Copy full SHA for a67b1cd

File tree

Expand file treeCollapse file tree

3 files changed

+122
-27
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+122
-27
lines changed

‎Cargo.lock

Copy file name to clipboardExpand all lines: Cargo.lock
+98-25Lines changed: 98 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

Copy file name to clipboardExpand all lines: Cargo.toml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ anyhow = "1.0.98"
2929
async-trait = "0.1.88"
3030
axum = "0.8.4"
3131
criterion = "0.6.0"
32-
diesel = "2.2.10"
32+
diesel = "2.2.11"
3333
diesel_migrations = "2.2.0"
3434
flate2 = "1.1.2"
3535
futures-util = "0.3.31"
3636
hex = "0.4.3"
3737
indicatif = "0.17.11"
3838
indoc = "2.0.6"
39-
liblzma = "0.4.1"
39+
liblzma = "0.4.2"
4040
md-5 = "0.10.6"
4141
num-format = "0.4.4"
4242
pgvector = "0.4.1"

‎postgresql_commands/src/traits.rs

Copy file name to clipboardExpand all lines: postgresql_commands/src/traits.rs
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,23 @@ use crate::error::{Error, Result};
22
use std::env::consts::OS;
33
use std::ffi::{OsStr, OsString};
44
use std::fmt::Debug;
5+
#[cfg(target_os = "windows")]
6+
use std::os::windows::process::CommandExt;
57
use std::path::PathBuf;
68
use std::process::ExitStatus;
79
use std::time::Duration;
810
use tracing::debug;
911

12+
/// Constant for the `CREATE_NO_WINDOW` flag on Windows to prevent the creation of a console window
13+
/// when executing commands. This is useful for background processes or services that do not require
14+
/// user interaction.
15+
///
16+
/// # References
17+
///
18+
/// - [Windows API: Process Creation Flags](https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags#flags)
19+
#[cfg(target_os = "windows")]
20+
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
21+
1022
/// Interface for `PostgreSQL` settings
1123
pub trait Settings {
1224
fn get_binary_dir(&self) -> PathBuf;
@@ -147,6 +159,11 @@ impl CommandExecutor for std::process::Command {
147159
let stderr: String;
148160
let status: ExitStatus;
149161

162+
#[cfg(target_os = "windows")]
163+
{
164+
self.creation_flags(CREATE_NO_WINDOW);
165+
}
166+
150167
if OS == "windows" && program.as_str().ends_with("pg_ctl") {
151168
// The pg_ctl process can hang on Windows when attempting to get stdout/stderr.
152169
let mut process = self
@@ -188,6 +205,11 @@ impl AsyncCommandExecutor for tokio::process::Command {
188205
let stderr: String;
189206
let status: ExitStatus;
190207

208+
#[cfg(target_os = "windows")]
209+
{
210+
self.creation_flags(CREATE_NO_WINDOW);
211+
}
212+
191213
if OS == "windows" && program.as_str().ends_with("pg_ctl") {
192214
// The pg_ctl process can hang on Windows when attempting to get stdout/stderr.
193215
let mut process = self

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.