aboutsummaryrefslogtreecommitdiff
path: root/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs
index a04b8e9b..94b5c427 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -5,6 +5,7 @@ use std::os::unix::process::CommandExt;
use std::path::PathBuf;
use std::process::{Command, Stdio};
use std::ptr::null_mut;
+use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Duration;
use anyhow::{ensure, Context};
@@ -53,6 +54,9 @@ pub fn make_screenshot_path(config: &Config) -> anyhow::Result<Option<PathBuf>>
Ok(Some(path))
}
+pub static REMOVE_ENV_RUST_BACKTRACE: AtomicBool = AtomicBool::new(false);
+pub static REMOVE_ENV_RUST_LIB_BACKTRACE: AtomicBool = AtomicBool::new(false);
+
/// Spawns the command to run independently of the compositor.
pub fn spawn(command: impl AsRef<OsStr>, args: impl IntoIterator<Item = impl AsRef<OsStr>>) {
let _span = tracy_client::span!();
@@ -66,6 +70,14 @@ pub fn spawn(command: impl AsRef<OsStr>, args: impl IntoIterator<Item = impl AsR
.stdout(Stdio::null())
.stderr(Stdio::null());
+ // Remove RUST_BACKTRACE and RUST_LIB_BACKTRACE from the environment if needed.
+ if REMOVE_ENV_RUST_BACKTRACE.load(Ordering::Relaxed) {
+ process.env_remove("RUST_BACKTRACE");
+ }
+ if REMOVE_ENV_RUST_LIB_BACKTRACE.load(Ordering::Relaxed) {
+ process.env_remove("RUST_LIB_BACKTRACE");
+ }
+
// Double-fork to avoid having to waitpid the child.
unsafe {
process.pre_exec(|| {