From d93f97309a881061e3f8b88fea79246402de6f6b Mon Sep 17 00:00:00 2001 From: s1341 Date: Thu, 16 Dec 2021 12:12:40 +0200 Subject: [PATCH] Open the stdout-file once (#419) Co-authored-by: Dominik Maier --- libafl/src/bolts/launcher.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libafl/src/bolts/launcher.rs b/libafl/src/bolts/launcher.rs index 134e06daa7..b8f8d9eda1 100644 --- a/libafl/src/bolts/launcher.rs +++ b/libafl/src/bolts/launcher.rs @@ -111,6 +111,13 @@ where println!("spawning on cores: {:?}", self.cores); + #[cfg(feature = "std")] + let stdout_file = if let Some(filename) = self.stdout_file { + Some(File::create(filename).unwrap()) + } else { + None + }; + // Spawn clients let mut index = 0_u64; for (id, bind_to) in core_ids.iter().enumerate().take(num_cores) { @@ -132,8 +139,7 @@ where std::thread::sleep(std::time::Duration::from_millis(index * 100)); #[cfg(feature = "std")] - if let Some(filename) = self.stdout_file { - let file = File::create(filename).unwrap(); + if let Some(file) = stdout_file { dup2(file.as_raw_fd(), libc::STDOUT_FILENO)?; dup2(file.as_raw_fd(), libc::STDERR_FILENO)?; }