More no-window flags (#7122)
This commit is contained in:
@@ -6,6 +6,8 @@ use tokio::process::Command;
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::{debug, info, warn};
|
||||
|
||||
use crate::subprocess::SubprocessExt;
|
||||
|
||||
use crate::agents::types::SessionConfig;
|
||||
use crate::agents::types::{
|
||||
RetryConfig, SuccessCheck, DEFAULT_ON_FAILURE_TIMEOUT_SECONDS, DEFAULT_RETRY_TIMEOUT_SECONDS,
|
||||
@@ -243,6 +245,8 @@ pub async fn execute_shell_command(
|
||||
cmd
|
||||
};
|
||||
|
||||
cmd.set_no_window();
|
||||
|
||||
let output = cmd
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
|
||||
@@ -4,6 +4,8 @@ use crate::config::paths::Paths;
|
||||
use crate::config::{get_enabled_extensions, Config};
|
||||
use crate::session::session_manager::CURRENT_SCHEMA_VERSION;
|
||||
use crate::session::SessionManager;
|
||||
#[cfg(target_os = "windows")]
|
||||
use crate::subprocess::SubprocessExt;
|
||||
use chrono::{DateTime, Utc};
|
||||
use once_cell::sync::Lazy;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -141,6 +143,7 @@ fn get_platform_version() -> Option<String> {
|
||||
{
|
||||
std::process::Command::new("cmd")
|
||||
.args(["/C", "ver"])
|
||||
.set_no_window()
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|o| String::from_utf8(o.stdout).ok())
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::subprocess::SubprocessExt;
|
||||
use chrono;
|
||||
use serde::Deserialize;
|
||||
use std::sync::Arc;
|
||||
@@ -134,6 +135,7 @@ impl AzureAuth {
|
||||
"--resource",
|
||||
"https://cognitiveservices.azure.com",
|
||||
])
|
||||
.set_no_window()
|
||||
.output()
|
||||
.await
|
||||
.map_err(|e| AuthError::TokenExchange(format!("Failed to execute Azure CLI: {}", e)))?;
|
||||
|
||||
@@ -3,13 +3,37 @@ use tokio::process::Command;
|
||||
#[cfg(windows)]
|
||||
const CREATE_NO_WINDOW_FLAG: u32 = 0x08000000;
|
||||
|
||||
pub trait SubprocessExt {
|
||||
fn set_no_window(&mut self) -> &mut Self;
|
||||
}
|
||||
|
||||
impl SubprocessExt for Command {
|
||||
fn set_no_window(&mut self) -> &mut Self {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
self.creation_flags(CREATE_NO_WINDOW_FLAG);
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl SubprocessExt for std::process::Command {
|
||||
fn set_no_window(&mut self) -> &mut Self {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
self.creation_flags(CREATE_NO_WINDOW_FLAG);
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn configure_subprocess(command: &mut Command) {
|
||||
// Isolate subprocess into its own process group so it does not receive
|
||||
// SIGINT when the user presses Ctrl+C in the terminal.
|
||||
#[cfg(unix)]
|
||||
command.process_group(0);
|
||||
|
||||
#[cfg(windows)]
|
||||
command.creation_flags(CREATE_NO_WINDOW_FLAG);
|
||||
command.set_no_window();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user