summaryrefslogtreecommitdiffhomepage
path: root/talpid-core/src
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-04-19 18:55:31 +0200
committerAndrej Mihajlov <and@mullvad.net>2018-04-23 21:51:59 +0200
commit308832d0df052dd4433bda2cc5c586ca9745c249 (patch)
treefb923fc7a264149837fe36d442b920bed8874a48 /talpid-core/src
parent8f6f61ebd6a013f657a2523dbe4b4cfa1a1cb462 (diff)
downloadmullvadvpn-308832d0df052dd4433bda2cc5c586ca9745c249.tar.xz
mullvadvpn-308832d0df052dd4433bda2cc5c586ca9745c249.zip
Add basic windows service
Diffstat (limited to 'talpid-core/src')
-rw-r--r--talpid-core/src/lib.rs1
-rw-r--r--talpid-core/src/process/openvpn.rs19
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