--- a/tests/process.rs
+++ b/tests/process.rs
@@ -4,6 +4,7 @@
 
 use bstr::ByteSlice;
 use sysinfo::{Pid, ProcessRefreshKind, ProcessesToUpdate, RefreshKind, System, UpdateKind};
+use std::path::Path;
 
 macro_rules! start_proc {
     ($time:literal, $name:literal) => {
@@ -101,9 +102,11 @@
     if !sysinfo::IS_SUPPORTED_SYSTEM || cfg!(feature = "apple-sandbox") {
         return;
     }
-    let file_name = "target/test_binary";
+    let target_dir = Path::new(option_env!("CARGO_TARGET_DIR").unwrap_or("target"));
+    let file_name = target_dir.join("test_binary");
+    let file_name = file_name.to_str().unwrap();
     build_test_binary(file_name);
-    let mut p = std::process::Command::new(format!("./{file_name}"))
+    let mut p = std::process::Command::new(file_name)
         .env("FOO", "BAR")
         .env("OTHER", "VALUE")
         .spawn()
@@ -138,7 +141,7 @@
     for _ in 0..SIZE {
         big_env.push('a');
     }
-    let mut p = std::process::Command::new("./target/test_binary")
+    let mut p = std::process::Command::new(file_name)
         .env("FOO", &big_env)
         .spawn()
         .unwrap();
@@ -920,9 +923,11 @@
         return;
     }
 
-    let file_name = "target/test_binary2";
+    let target_dir = Path::new(option_env!("CARGO_TARGET_DIR").unwrap_or("target"));
+    let file_name = target_dir.join("test_binary2");
+    let file_name = file_name.to_str().unwrap();
     build_test_binary(file_name);
-    let mut p = std::process::Command::new(format!("./{file_name}"))
+    let mut p = std::process::Command::new(file_name)
         .arg("1")
         .spawn()
         .unwrap();
@@ -969,13 +974,15 @@
         return;
     }
 
-    let file_name = "target/test_binary3";
+    let target_dir = Path::new(option_env!("CARGO_TARGET_DIR").unwrap_or("target"));
+    let file_name = target_dir.join("test_binary3");
+    let file_name = file_name.to_str().unwrap();
     build_test_binary(file_name);
-    let mut p_a = std::process::Command::new(format!("./{file_name}"))
+    let mut p_a = std::process::Command::new(file_name)
         .arg("1")
         .spawn()
         .unwrap();
-    let mut p_b = std::process::Command::new(format!("./{file_name}"))
+    let mut p_b = std::process::Command::new(file_name)
         .arg("1")
         .spawn()
         .unwrap();
@@ -1073,9 +1080,11 @@
         return;
     }
 
-    let file_name = "target/test_binary4";
+    let target_dir = Path::new(option_env!("CARGO_TARGET_DIR").unwrap_or("target"));
+    let file_name = target_dir.join("test_binary4");
+    let file_name = file_name.to_str().unwrap();
     build_test_binary(file_name);
-    let mut p = std::process::Command::new(format!("./{file_name}"))
+    let mut p = std::process::Command::new(file_name)
         .arg("1")
         .spawn()
         .unwrap();
