summaryrefslogtreecommitdiffhomepage
path: root/src/process
diff options
context:
space:
mode:
authorErik Larkö <erik@mullvad.net>2017-01-12 15:18:38 +0100
committerErik Larkö <erik@mullvad.net>2017-01-13 13:40:25 +0100
commit1b7ca8272a9f8d914da13e2ea3e852588f1e23e7 (patch)
tree7b76a029543e295bb1f8d975fd546ba62bae9097 /src/process
parent35e666b1cb4bfe5d61f4da4813bbfe4c1868ef08 (diff)
downloadmullvadvpn-1b7ca8272a9f8d914da13e2ea3e852588f1e23e7.tar.xz
mullvadvpn-1b7ca8272a9f8d914da13e2ea3e852588f1e23e7.zip
Show that the pipe only affect stdout and stderr
Diffstat (limited to 'src/process')
-rw-r--r--src/process/mod.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/process/mod.rs b/src/process/mod.rs
index e469ce7b58..52d4229d17 100644
--- a/src/process/mod.rs
+++ b/src/process/mod.rs
@@ -19,7 +19,7 @@ pub struct OpenVpnCommand {
openvpn_bin: OsString,
config: Option<PathBuf>,
remotes: Vec<RemoteAddr>,
- forward_standard_streams: bool,
+ pipe_output: bool,
}
impl OpenVpnCommand {
@@ -30,7 +30,7 @@ impl OpenVpnCommand {
openvpn_bin: OsString::from(openvpn_bin.as_ref()),
config: None,
remotes: vec![],
- forward_standard_streams: true,
+ pipe_output: true,
}
}
@@ -47,9 +47,11 @@ impl OpenVpnCommand {
Ok(self)
}
- /// Invoke this to not create stdout and stderr streams for the subprocess
- pub fn discard_standard_streams(&mut self) -> &mut Self {
- self.forward_standard_streams = false;
+ /// If piping the standard streams, stdout and stderr will be available to the parent process.
+ /// This is the default behavior. If you want the equivalence of attaching the child streams to
+ /// /dev/null, invoke this method with false.
+ pub fn pipe_output(&mut self, pipe_output: bool) -> &mut Self {
+ self.pipe_output = pipe_output;
self
}
@@ -64,13 +66,13 @@ impl OpenVpnCommand {
let mut command = Command::new(&self.openvpn_bin);
command.env_clear()
.stdin(Stdio::null())
- .stdout(self.get_std_streams_forward_policy())
- .stderr(self.get_std_streams_forward_policy());
+ .stdout(self.get_output_pipe_policy())
+ .stderr(self.get_output_pipe_policy());
command
}
- fn get_std_streams_forward_policy(&self) -> Stdio {
- if self.forward_standard_streams {
+ fn get_output_pipe_policy(&self) -> Stdio {
+ if self.pipe_output {
Stdio::piped()
} else {
Stdio::null()