Launcher: restore fs::File but open just before dup2
This commit is contained in:
parent
ab7672c8d1
commit
279fb3f213
@ -18,7 +18,7 @@ use crate::bolts::os::startable_self;
|
|||||||
use crate::bolts::os::{dup2, fork, ForkResult};
|
use crate::bolts::os::{dup2, fork, ForkResult};
|
||||||
|
|
||||||
#[cfg(all(unix, feature = "std"))]
|
#[cfg(all(unix, feature = "std"))]
|
||||||
use std::ffi::CString;
|
use std::{fs::File, os::unix::io::AsRawFd};
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
@ -98,16 +98,6 @@ where
|
|||||||
let mut handles = vec![];
|
let mut handles = vec![];
|
||||||
|
|
||||||
println!("spawning on cores: {:?}", self.cores);
|
println!("spawning on cores: {:?}", self.cores);
|
||||||
let file = self.stdout_file.map(|filename| {
|
|
||||||
let fname = CString::new(filename).unwrap();
|
|
||||||
unsafe {
|
|
||||||
libc::open(
|
|
||||||
fname.as_ptr(),
|
|
||||||
libc::O_WRONLY | libc::O_CREAT | libc::O_TRUNC,
|
|
||||||
0666,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Spawn clients
|
// Spawn clients
|
||||||
for (index, (id, bind_to)) in core_ids.iter().enumerate().take(num_cores).enumerate() {
|
for (index, (id, bind_to)) in core_ids.iter().enumerate().take(num_cores).enumerate() {
|
||||||
@ -128,10 +118,10 @@ where
|
|||||||
std::thread::sleep(std::time::Duration::from_secs((index + 1) as u64));
|
std::thread::sleep(std::time::Duration::from_secs((index + 1) as u64));
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
if let Some(fd) = file {
|
if let Some(filename) = self.stdout_file {
|
||||||
dup2(fd, libc::STDOUT_FILENO)?;
|
let file = File::create(filename).unwrap();
|
||||||
dup2(fd, libc::STDERR_FILENO)?;
|
dup2(file.as_raw_fd(), libc::STDOUT_FILENO)?;
|
||||||
unsafe { libc::close(fd) };
|
dup2(file.as_raw_fd(), libc::STDERR_FILENO)?;
|
||||||
}
|
}
|
||||||
// Fuzzer client. keeps retrying the connection to broker till the broker starts
|
// Fuzzer client. keeps retrying the connection to broker till the broker starts
|
||||||
let (state, mgr) = RestartingMgr::<I, OT, S, SP, ST>::builder()
|
let (state, mgr) = RestartingMgr::<I, OT, S, SP, ST>::builder()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user