disable process group for dotnets

This commit is contained in:
Ruben Fiszel
2025-08-13 16:46:14 +00:00
parent 569688d8bd
commit ce76b16d0c
15 changed files with 64 additions and 61 deletions
+10 -10
View File
@@ -78,7 +78,7 @@ async fn clone_repo(
clone_cmd.arg(&repo.url);
clone_cmd.arg(&target_path);
let clone_cmd_child = start_child_process(clone_cmd, GIT_PATH.as_str()).await?;
let clone_cmd_child = start_child_process(clone_cmd, GIT_PATH.as_str(), false).await?;
handle_child(
job_id,
conn,
@@ -112,7 +112,7 @@ async fn clone_repo(
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let checkout_cmd_child = start_child_process(checkout_cmd, GIT_PATH.as_str()).await?;
let checkout_cmd_child = start_child_process(checkout_cmd, GIT_PATH.as_str(), false).await?;
handle_child(
job_id,
conn,
@@ -217,7 +217,7 @@ async fn clone_repo_without_history(
init_cmd.args(["--initial-branch", branch]);
}
let init_cmd_child = start_child_process(init_cmd, GIT_PATH.as_str()).await?;
let init_cmd_child = start_child_process(init_cmd, GIT_PATH.as_str(), false).await?;
handle_child(
job_id,
conn,
@@ -249,7 +249,7 @@ async fn clone_repo_without_history(
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let add_remote_cmd_child = start_child_process(add_remote_cmd, GIT_PATH.as_str()).await?;
let add_remote_cmd_child = start_child_process(add_remote_cmd, GIT_PATH.as_str(), false).await?;
handle_child(
job_id,
conn,
@@ -281,7 +281,7 @@ async fn clone_repo_without_history(
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let fetch_cmd_child = start_child_process(fetch_cmd, GIT_PATH.as_str()).await?;
let fetch_cmd_child = start_child_process(fetch_cmd, GIT_PATH.as_str(), false).await?;
handle_child(
job_id,
conn,
@@ -313,7 +313,7 @@ async fn clone_repo_without_history(
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let checkout_cmd_child = start_child_process(checkout_cmd, GIT_PATH.as_str()).await?;
let checkout_cmd_child = start_child_process(checkout_cmd, GIT_PATH.as_str(), false).await?;
handle_child(
job_id,
conn,
@@ -447,7 +447,7 @@ pub async fn install_galaxy_collections(
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let child = start_child_process(galaxy_roles_cmd, ANSIBLE_GALAXY_PATH.as_str()).await?;
let child = start_child_process(galaxy_roles_cmd, ANSIBLE_GALAXY_PATH.as_str(), false).await?;
handle_child(
job_id,
conn,
@@ -484,7 +484,7 @@ pub async fn install_galaxy_collections(
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let child = start_child_process(galaxy_collections_cmd, ANSIBLE_GALAXY_PATH.as_str()).await?;
let child = start_child_process(galaxy_collections_cmd, ANSIBLE_GALAXY_PATH.as_str(), false).await?;
handle_child(
job_id,
conn,
@@ -1096,7 +1096,7 @@ fi
)
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), false).await?
} else {
let mut ansible_cmd = Command::new(ANSIBLE_PLAYBOOK_PATH.as_str());
ansible_cmd
@@ -1115,7 +1115,7 @@ fi
#[cfg(windows)]
ansible_cmd.env("USERPROFILE", crate::USERPROFILE_ENV.as_str());
start_child_process(ansible_cmd, ANSIBLE_PLAYBOOK_PATH.as_str()).await?
start_child_process(ansible_cmd, ANSIBLE_PLAYBOOK_PATH.as_str(), false).await?
};
handle_child(
+5 -5
View File
@@ -198,7 +198,7 @@ exit $exit_status
.args(cmd_args)
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), false).await?
} else {
let mut cmd_args = vec!["wrapper.sh"];
cmd_args.extend(&args);
@@ -214,7 +214,7 @@ exit $exit_status
.args(cmd_args)
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(bash_cmd, BIN_BASH.as_str()).await?
start_child_process(bash_cmd, BIN_BASH.as_str(), false).await?
};
handle_child(
&job.id,
@@ -630,7 +630,7 @@ pub async fn handle_powershell_job(
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let child = start_child_process(cmd, POWERSHELL_PATH.as_str()).await?;
let child = start_child_process(cmd, POWERSHELL_PATH.as_str(), false).await?;
handle_child(
&job.id,
@@ -779,7 +779,7 @@ $env:PSModulePath = \"{};$PSModulePathBackup\"",
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(cmd, NSJAIL_PATH.as_str()).await?
start_child_process(cmd, NSJAIL_PATH.as_str(), false).await?
} else {
let mut cmd;
let mut cmd_args;
@@ -852,7 +852,7 @@ $env:PSModulePath = \"{};$PSModulePathBackup\"",
.env("USERPROFILE", crate::USERPROFILE_ENV.as_str());
}
start_child_process(cmd, POWERSHELL_PATH.as_str()).await?
start_child_process(cmd, POWERSHELL_PATH.as_str(), false).await?
};
handle_child(
+9 -8
View File
@@ -20,9 +20,9 @@ use crate::{
read_file_content, read_result, start_child_process, write_file_binary, OccupancyMetrics,
},
handle_child::handle_child,
BUNFIG_INSTALL_SCOPES, BUN_BUNDLE_CACHE_DIR, BUN_CACHE_DIR, BUN_NO_CACHE, BUN_PATH, DISABLE_NSJAIL,
DISABLE_NUSER, HOME_ENV, NODE_BIN_PATH, NODE_PATH, NPM_CONFIG_REGISTRY, NPM_PATH, NSJAIL_PATH,
PATH_ENV, PROXY_ENVS, TZ_ENV,
BUNFIG_INSTALL_SCOPES, BUN_BUNDLE_CACHE_DIR, BUN_CACHE_DIR, BUN_NO_CACHE, BUN_PATH,
DISABLE_NSJAIL, DISABLE_NUSER, HOME_ENV, NODE_BIN_PATH, NODE_PATH, NPM_CONFIG_REGISTRY,
NPM_PATH, NSJAIL_PATH, PATH_ENV, PROXY_ENVS, TZ_ENV,
};
use windmill_common::client::AuthedClient;
@@ -151,7 +151,7 @@ pub async fn gen_bun_lockfile(
#[cfg(windows)]
child_cmd.env("SystemRoot", SYSTEM_ROOT.as_str());
let mut child_process = start_child_process(child_cmd, &*BUN_PATH).await?;
let mut child_process = start_child_process(child_cmd, &*BUN_PATH, false).await?;
if let Some(db) = db {
handle_child(
@@ -356,7 +356,7 @@ pub async fn install_bun_lockfile(
}
}
let mut child_process = start_child_process(child_cmd, &*BUN_PATH).await?;
let mut child_process = start_child_process(child_cmd, &*BUN_PATH, false).await?;
gen_bunfig(job_dir).await?;
if let Some(db) = db {
@@ -531,7 +531,7 @@ pub async fn generate_wrapper_mjs(
#[cfg(windows)]
child.env("SystemRoot", SYSTEM_ROOT.as_str());
let child_process = start_child_process(child, &*BUN_PATH).await?;
let child_process = start_child_process(child, &*BUN_PATH, false).await?;
handle_child(
job_id,
db,
@@ -581,7 +581,7 @@ pub async fn generate_bun_bundle(
#[cfg(windows)]
child.env("SystemRoot", SYSTEM_ROOT.as_str());
let mut child_process = start_child_process(child, &*BUN_PATH).await?;
let mut child_process = start_child_process(child, &*BUN_PATH, false).await?;
if let Some(db) = db {
handle_child(
job_id,
@@ -1399,7 +1399,7 @@ try {{
.args(args)
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), false).await?
} else {
let cmd = if annotation.nodejs {
let script_path = format!("{job_dir}/wrapper.mjs");
@@ -1458,6 +1458,7 @@ try {{
} else {
&*BUN_PATH
},
false,
)
.await?
};
+4 -3
View File
@@ -649,11 +649,12 @@ lazy_static! {
pub async fn start_child_process(
cmd: Command,
executable: &str,
disable_process_group: bool,
) -> Result<Box<dyn TokioChildWrapper>, Error> {
use process_wrap::tokio::*;
let mut cmd = TokioCommandWrap::from(cmd);
if !*DISABLE_PROCESS_GROUP && !executable.starts_with("dotnet ") {
if !*DISABLE_PROCESS_GROUP && !disable_process_group {
#[cfg(unix)]
{
use process_wrap::tokio::ProcessGroup;
@@ -1343,7 +1344,7 @@ pub async fn par_install_language_dependencies<'a>(
short_name: short_name.clone(),
})?;
tracing::debug!("{:?}", &cmd);
Some(start_child_process(cmd, &installer_executable_name).await?)
Some(start_child_process(cmd, &installer_executable_name, false).await?)
} else {
None
}
@@ -1540,7 +1541,7 @@ pub async fn par_install_language_dependencies<'a>(
.await;
let cmd = callback(not_pulled_copy.clone())?;
tracing::debug!("{:?}", &cmd);
let child = start_child_process(cmd, &installer_executable_name).await?;
let child = start_child_process(cmd, &installer_executable_name, false).await?;
let mut buf = "".to_owned();
let pipe_stdout = if stdout_on_err { Some(&mut buf) } else { None };
if let Err(e) = crate::handle_child::handle_child(
@@ -113,7 +113,8 @@ pub async fn generate_nuget_lockfile(
.unwrap_or_else(|_| format!("{}\\AppData\\Local", HOME_ENV.as_str())),
);
let gen_lockfile_process = start_child_process(gen_lockfile_cmd, DOTNET_PATH.as_str()).await?;
let gen_lockfile_process =
start_child_process(gen_lockfile_cmd, DOTNET_PATH.as_str(), true).await?;
handle_child(
job_id,
conn,
@@ -370,7 +371,7 @@ async fn build_cs_proj(
.unwrap_or_else(|_| format!("{}\\AppData\\Local", HOME_ENV.as_str())),
);
let build_cs_process = start_child_process(build_cs_cmd, DOTNET_PATH.as_str()).await?;
let build_cs_process = start_child_process(build_cs_cmd, DOTNET_PATH.as_str(), true).await?;
handle_child(
job_id,
conn,
@@ -575,7 +576,7 @@ pub async fn handle_csharp_job(
#[cfg(windows)]
nsjail_cmd.env("SystemRoot", SYSTEM_ROOT.as_str());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), true).await?
} else {
#[cfg(unix)]
let compiled_executable_name = "./Main".to_string();
@@ -624,7 +625,7 @@ pub async fn handle_csharp_job(
.unwrap_or_else(|_| format!("{}\\AppData\\Local", HOME_ENV.as_str())),
);
start_child_process(run_csharp, &compiled_executable_name).await?
start_child_process(run_csharp, &compiled_executable_name, true).await?
};
handle_child(
@@ -98,7 +98,7 @@ pub async fn handle_dedicated_process(
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(cmd, command_path).await?
start_child_process(cmd, command_path, false).await?
};
let stdout = child
+2 -2
View File
@@ -144,7 +144,7 @@ pub async fn generate_deno_lock(
.envs(deno_envs)
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let mut child_process = start_child_process(child_cmd, DENO_PATH.as_str()).await?;
let mut child_process = start_child_process(child_cmd, DENO_PATH.as_str(), false).await?;
if let Some(db) = db {
handle_child(
@@ -414,7 +414,7 @@ try {{
.args(args)
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(deno_cmd, DENO_PATH.as_str()).await?
start_child_process(deno_cmd, DENO_PATH.as_str(), false).await?
};
// logs.push_str(format!("prepare: {:?}\n", start.elapsed().as_micros()).as_str());
// start = Instant::now();
+5 -5
View File
@@ -259,7 +259,7 @@ func Run(req Req) (interface{{}}, error){{
#[cfg(windows)]
set_windows_env_vars(&mut build_go_cmd);
let build_go_process = start_child_process(build_go_cmd, GO_PATH.as_str()).await?;
let build_go_process = start_child_process(build_go_cmd, GO_PATH.as_str(), false).await?;
handle_child(
&job.id,
conn,
@@ -363,7 +363,7 @@ func Run(req Req) (interface{{}}, error){{
.args(vec!["--config", "run.config.proto", "--", "/tmp/go/main"])
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), false).await?
} else {
#[cfg(unix)]
let compiled_executable_name = "./main";
@@ -406,7 +406,7 @@ func Run(req Req) (interface{{}}, error){{
set_windows_env_vars(&mut run_go);
run_go.stdout(Stdio::piped()).stderr(Stdio::piped());
start_child_process(run_go, &compiled_executable_name).await?
start_child_process(run_go, &compiled_executable_name, false).await?
};
let handle_result = handle_child(
&job.id,
@@ -490,7 +490,7 @@ pub async fn install_go_dependencies(
#[cfg(windows)]
set_windows_env_vars(&mut child_cmd);
let child_process = start_child_process(child_cmd, GO_PATH.as_str()).await?;
let child_process = start_child_process(child_cmd, GO_PATH.as_str(), false).await?;
handle_child(
job_id,
@@ -582,7 +582,7 @@ pub async fn install_go_dependencies(
#[cfg(windows)]
set_windows_env_vars(&mut child_cmd);
let child_process = start_child_process(child_cmd, GO_PATH.as_str()).await?;
let child_process = start_child_process(child_cmd, GO_PATH.as_str(), false).await?;
handle_child(
job_id,
+3 -3
View File
@@ -518,7 +518,7 @@ async fn compile<'a>(
std::env::var("TMP").unwrap_or_else(|_| String::from("/tmp")),
);
}
start_child_process(cmd, "javac").await?
start_child_process(cmd, "javac", false).await?
};
handle_child::handle_child(
&job.id,
@@ -642,7 +642,7 @@ async fn run<'a>(
cmd.args(vec!["-classpath", &classpath, "net.script.App"]);
cmd.stdout(Stdio::piped()).stderr(Stdio::piped());
start_child_process(cmd, NSJAIL_PATH.as_str()).await?
start_child_process(cmd, NSJAIL_PATH.as_str(), false).await?
} else {
append_logs(
&job.id,
@@ -701,7 +701,7 @@ async fn run<'a>(
std::env::var("TMP").unwrap_or_else(|_| String::from("/tmp")),
);
}
start_child_process(cmd, "java").await?
start_child_process(cmd, "java", false).await?
};
handle_child::handle_child(
&job.id,
+3 -3
View File
@@ -118,7 +118,7 @@ pub async fn handle_nu_job<'a>(mut args: JobHandlerInput<'a>) -> Result<Box<RawV
// #[cfg(windows)]
// nsjail_cmd.env("SystemRoot", SYSTEM_ROOT.as_str());
// let child = start_child_process(run_cmd, "cargo").await?;
// let child = start_child_process(run_cmd, "cargo", false).await?;
// // handle_child::handle_child(
// // &job.id,
// // db,
@@ -272,7 +272,7 @@ async fn run<'a>(
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), false).await?
} else {
append_logs(
&job.id,
@@ -323,7 +323,7 @@ async fn run<'a>(
std::env::var("TMP").unwrap_or_else(|_| String::from("/tmp")),
);
}
start_child_process(cmd, "nu").await?
start_child_process(cmd, "nu", false).await?
};
handle_child::handle_child(
&job.id,
+3 -3
View File
@@ -90,7 +90,7 @@ pub async fn composer_install(
.args(args)
.stdout(Stdio::piped())
.stderr(Stdio::piped());
let child_process = start_child_process(child_cmd, &*COMPOSER_PATH).await?;
let child_process = start_child_process(child_cmd, &*COMPOSER_PATH, false).await?;
handle_child(
job_id,
@@ -306,7 +306,7 @@ try {{
.args(args)
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), false).await?
} else {
let cmd = {
let script_path = format!("{job_dir}/wrapper.php");
@@ -325,7 +325,7 @@ try {{
.stderr(Stdio::piped());
php_cmd
};
start_child_process(cmd, &*PHP_PATH).await?
start_child_process(cmd, &*PHP_PATH, false).await?
};
handle_child(
@@ -369,7 +369,7 @@ pub async fn uv_pip_compile(
);
}
let child_process = start_child_process(child_cmd, uv_cmd).await?;
let child_process = start_child_process(child_cmd, uv_cmd, false).await?;
append_logs(&job_id, &w_id, logs, conn).await;
handle_child(
job_id,
@@ -830,7 +830,7 @@ mount {{
])
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), false).await?
} else {
let mut python_cmd = Command::new(&python_path);
@@ -859,7 +859,7 @@ mount {{
);
}
start_child_process(python_cmd, &python_path).await?
start_child_process(python_cmd, &python_path, false).await?
};
let handle_result = handle_child(
@@ -1362,7 +1362,7 @@ async fn spawn_uv_install(
.args(vec!["--config", &nsjail_proto])
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), false).await
} else {
#[cfg(unix)]
let req = req.to_owned();
@@ -1445,7 +1445,7 @@ async fn spawn_uv_install(
.args(&command_args[1..])
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(cmd, UV_PATH.as_str()).await
start_child_process(cmd, UV_PATH.as_str(), false).await
}
#[cfg(windows)]
@@ -1496,7 +1496,7 @@ async fn spawn_uv_install(
.args(&command_args[1..])
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(cmd, "uv").await
start_child_process(cmd, "uv", false).await
}
}
}
@@ -638,7 +638,7 @@ impl PyV {
);
}
let child_process = start_child_process(child_cmd, "uv").await?;
let child_process = start_child_process(child_cmd, "uv", false).await?;
append_logs(&job_id, &w_id, logs, conn).await;
handle_child(
+6 -6
View File
@@ -175,7 +175,7 @@ pub async fn generate_cargo_lockfile(
std::env::var("TMP").unwrap_or_else(|_| "C:\\tmp".to_string()),
);
}
let gen_lockfile_process = start_child_process(gen_lockfile_cmd, CARGO_PATH.as_str()).await?;
let gen_lockfile_process = start_child_process(gen_lockfile_cmd, CARGO_PATH.as_str(), false).await?;
handle_child(
job_id,
conn,
@@ -282,7 +282,7 @@ async fn get_build_dir(
);
tokio::spawn(async move {
if let Err(e) = match start_child_process(sweep_cmd, CARGO_PATH.as_str()).await {
if let Err(e) = match start_child_process(sweep_cmd, CARGO_PATH.as_str(), false).await {
Ok(sweep_process) => {
handle_child(
&job_id,
@@ -365,7 +365,7 @@ pub async fn build_rust_crate(
if !is_preview {
nsjail_cmd.arg("--release");
}
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), false).await?
} else {
let mut build_rust_cmd = Command::new(CARGO_PATH.as_str());
build_rust_cmd
@@ -394,7 +394,7 @@ pub async fn build_rust_crate(
);
build_rust_cmd.env("USERPROFILE", crate::USERPROFILE_ENV.as_str());
}
start_child_process(build_rust_cmd, CARGO_PATH.as_str()).await?
start_child_process(build_rust_cmd, CARGO_PATH.as_str(), false).await?
};
handle_child(
&job.id,
@@ -560,7 +560,7 @@ pub async fn handle_rust_job(
.args(vec!["--config", "run.config.proto", "--", "/tmp/main"])
.stdout(Stdio::piped())
.stderr(Stdio::piped());
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str()).await?
start_child_process(nsjail_cmd, NSJAIL_PATH.as_str(), false).await?
} else {
let compiled_executable_name = "./main";
let mut run_rust = Command::new(compiled_executable_name);
@@ -582,7 +582,7 @@ pub async fn handle_rust_job(
run_rust.env("USERPROFILE", crate::USERPROFILE_ENV.as_str());
}
start_child_process(run_rust, compiled_executable_name).await?
start_child_process(run_rust, compiled_executable_name, false).await?
};
handle_child(
&job.id,
@@ -1892,7 +1892,7 @@ pub async fn handle_app_dependency_job(
// .args(args)
// .stdout(Stdio::piped())
// .stderr(Stdio::piped());
// let child = start_child_process(cmd, "esbuild").await?;
// let child = start_child_process(cmd, "esbuild", false).await?;
// crate::handle_child::handle_child(
// &job.id,