Fix: start process on windows

This commit is contained in:
gaofei 2025-01-15 10:51:23 +08:00
parent 9c9483f070
commit 35ad80dc13

View File

@ -102,6 +102,12 @@ pub fn start_process(
.stdout(Stdio::from(stdout_log)) .stdout(Stdio::from(stdout_log))
.stderr(Stdio::from(stderr_log)); .stderr(Stdio::from(stderr_log));
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
cmd.creation_flags(0x00000008 | 0x00000200); // CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS
}
match cmd.spawn() { match cmd.spawn() {
Ok(child) => { Ok(child) => {
let pid = child.id(); let pid = child.id();
@ -152,6 +158,12 @@ pub fn start_process(
.stdout(Stdio::from(stdout_log)) .stdout(Stdio::from(stdout_log))
.stderr(Stdio::from(stderr_log)); .stderr(Stdio::from(stderr_log));
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
cmd.creation_flags(0x00000008 | 0x00000200); // CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS
}
match cmd.spawn() { match cmd.spawn() {
Ok(child) => { Ok(child) => {
let pid = child.id(); let pid = child.id();
@ -205,6 +217,12 @@ fn start_existing_process(process: &PmrProcessInfo) -> io::Result<()> {
.stdout(Stdio::from(stdout_log)) .stdout(Stdio::from(stdout_log))
.stderr(Stdio::from(stderr_log)); .stderr(Stdio::from(stderr_log));
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
cmd.creation_flags(0x00000008 | 0x00000200); // CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS
}
match cmd.spawn() { match cmd.spawn() {
Ok(child) => { Ok(child) => {
let pid = child.id(); let pid = child.id();