use super::*;
pub(super) fn apply_client_env(
cmd: &mut tokio::process::Command,
client_env: &Option<Vec<(String, String)>>,
lineage: &super::super::lineage::Lineage,
) {
if let Some(vars) = client_env {
cmd.env_clear();
for (key, val) in vars {
if client_env_var_is_safe_to_replay(key) {
cmd.env(key, val);
}
}
}
lineage.apply_to_tokio(cmd, client_env.as_deref());
}
pub(super) fn client_env_var_is_safe_to_replay(key: &str) -> bool {
!matches!(key, "MAKEFLAGS" | "CARGO_MAKEFLAGS")
}
pub(super) fn apply_client_env_sync(
cmd: &mut std::process::Command,
client_env: Option<&[(String, String)]>,
lineage: &super::super::lineage::Lineage,
) {
if let Some(vars) = client_env {
cmd.env_clear();
for (key, val) in vars {
if client_env_var_is_safe_to_replay(key) {
cmd.env(key, val);
}
}
}
lineage.apply_to_sync(cmd, client_env);
}
pub(super) fn session_client_pid(state: &SharedState, sid: &SessionId) -> Option<u32> {
state.sessions.get(sid).map(|s| s.client_pid)
}