use std::process::Command; fn main() -> anyhow::Result<()> { println!("Hello, split_bins!"); println!("startup processes"); let executables = vec!["split_bins_plugin"]; //, "split_bins_plugin_two"]; let current_exe_path: String = get_current_exe_path()?; let mut handles = vec![]; for exe in executables { let curr_exe_path = current_exe_path.clone(); let e = exe.clone(); handles.push(std::thread::spawn(move || { println!("current exe path: {}", curr_exe_path); let (server, name) = ipc_channel::ipc::IpcOneShotServer::new().expect("could not create oneshot server"); let mut child = Command::new(format!("{}/{}", curr_exe_path, e)) .arg(format!("{}", name.clone())) .spawn() .expect(format!("started process: {}", curr_exe_path).as_str()); let (_, tx): (_, ipc_channel::ipc::IpcSender) = server.accept().unwrap(); tx.send("some msg".into()).expect("could not send message"); child.wait().expect("did not finish with 0"); })); } for handle in handles { if let Err(_) = handle.join() { return Err(anyhow::anyhow!("handle failed to return with statuscode=0")); } } Ok(()) } fn get_current_exe_path() -> anyhow::Result { let mut current_exe_path = std::env::current_exe()?; current_exe_path.pop(); return Ok(current_exe_path.to_string_lossy().to_string()); }