Launcher: Allow setting a distinct stderr redirect (#1329)
Co-authored-by: Dominik Maier <domenukk@gmail.com>
This commit is contained in:
parent
f76331eac7
commit
11fc57a5d7
@ -78,6 +78,10 @@ where
|
|||||||
/// A file name to write all client output to
|
/// A file name to write all client output to
|
||||||
#[builder(default = None)]
|
#[builder(default = None)]
|
||||||
stdout_file: Option<&'a str>,
|
stdout_file: Option<&'a str>,
|
||||||
|
/// A file name to write all client stderr output to. If not specified, output is sent to
|
||||||
|
/// `stdout_file`.
|
||||||
|
#[builder(default = None)]
|
||||||
|
stderr_file: Option<&'a str>,
|
||||||
/// The `ip:port` address of another broker to connect our new broker to for multi-machine
|
/// The `ip:port` address of another broker to connect our new broker to for multi-machine
|
||||||
/// clusters.
|
/// clusters.
|
||||||
#[builder(default = None)]
|
#[builder(default = None)]
|
||||||
@ -110,6 +114,7 @@ where
|
|||||||
.field("spawn_broker", &self.spawn_broker)
|
.field("spawn_broker", &self.spawn_broker)
|
||||||
.field("remote_broker_addr", &self.remote_broker_addr)
|
.field("remote_broker_addr", &self.remote_broker_addr)
|
||||||
.field("stdout_file", &self.stdout_file)
|
.field("stdout_file", &self.stdout_file)
|
||||||
|
.field("stderr_file", &self.stderr_file)
|
||||||
.finish_non_exhaustive()
|
.finish_non_exhaustive()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,6 +153,10 @@ where
|
|||||||
let stdout_file = self
|
let stdout_file = self
|
||||||
.stdout_file
|
.stdout_file
|
||||||
.map(|filename| File::create(filename).unwrap());
|
.map(|filename| File::create(filename).unwrap());
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
let stderr_file = self
|
||||||
|
.stderr_file
|
||||||
|
.map(|filename| File::create(filename).unwrap());
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
let debug_output = std::env::var("LIBAFL_DEBUG_OUTPUT").is_ok();
|
let debug_output = std::env::var("LIBAFL_DEBUG_OUTPUT").is_ok();
|
||||||
@ -176,7 +185,11 @@ where
|
|||||||
if !debug_output {
|
if !debug_output {
|
||||||
if let Some(file) = stdout_file {
|
if let Some(file) = stdout_file {
|
||||||
dup2(file.as_raw_fd(), libc::STDOUT_FILENO)?;
|
dup2(file.as_raw_fd(), libc::STDOUT_FILENO)?;
|
||||||
dup2(file.as_raw_fd(), libc::STDERR_FILENO)?;
|
if let Some(stderr) = stderr_file {
|
||||||
|
dup2(stderr.as_raw_fd(), libc::STDERR_FILENO)?;
|
||||||
|
} else {
|
||||||
|
dup2(file.as_raw_fd(), libc::STDERR_FILENO)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user