diff options
Diffstat (limited to 'talpid-core/src')
| -rw-r--r-- | talpid-core/src/lib.rs | 1 | ||||
| -rw-r--r-- | talpid-core/src/process/openvpn.rs | 19 |
2 files changed, 19 insertions, 1 deletions
diff --git a/talpid-core/src/lib.rs b/talpid-core/src/lib.rs index fc85584267..6c6e907255 100644 --- a/talpid-core/src/lib.rs +++ b/talpid-core/src/lib.rs @@ -10,6 +10,7 @@ //! GNU General Public License as published by the Free Software Foundation, either version 3 of //! the License, or (at your option) any later version. +extern crate atty; extern crate duct; #[macro_use] diff --git a/talpid-core/src/process/openvpn.rs b/talpid-core/src/process/openvpn.rs index f315e86eb5..734918853f 100644 --- a/talpid-core/src/process/openvpn.rs +++ b/talpid-core/src/process/openvpn.rs @@ -1,3 +1,4 @@ +use atty; use duct; use std::ffi::{OsStr, OsString}; @@ -106,7 +107,23 @@ impl OpenVpnCommand { /// Build a runnable expression from the current state of the command. pub fn build(&self) -> duct::Expression { debug!("Building expression: {}", &self); - duct::cmd(&self.openvpn_bin, self.get_arguments()).unchecked() + + let mut cmd = duct::cmd(&self.openvpn_bin, self.get_arguments()).unchecked(); + + // Prevent forwarding the stdio when it's not available. + if atty::is(atty::Stream::Stdin) { + cmd = cmd.stdin_null(); + } + + if atty::is(atty::Stream::Stdout) { + cmd = cmd.stdout_null(); + } + + if atty::is(atty::Stream::Stderr) { + cmd = cmd.stderr_null(); + } + + cmd } /// Sets extra options |
