Skip to content

Commit

Permalink
fix aardvark output logic
Browse files Browse the repository at this point in the history
When we have debug level we want stderr connected. If this is not the
case we should use /dev/null.

Also do not connect stdin and use Stdio::inherit() instead of the unsafe
call.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Feb 11, 2022
1 parent 6d59e4e commit e915318
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dns/aardvark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::io::prelude::*;
use std::io::Result;
use std::net::IpAddr;
use std::net::Ipv4Addr;
use std::os::unix::prelude::FromRawFd;
use std::path::Path;
use std::process::{Command, Stdio};

Expand Down Expand Up @@ -103,12 +102,13 @@ impl Aardvark {
log::debug!("start aardvark-dns: {:?}", aardvark_args);

let output = match log_enabled!(log::Level::Debug) {
true => Stdio::null(),
false => unsafe { Stdio::from_raw_fd(2) },
true => Stdio::inherit(),
false => Stdio::null(),
};

Command::new(&aardvark_args[0])
.args(&aardvark_args[1..])
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(output)
// set RUST_LOG for aardvark
Expand Down

0 comments on commit e915318

Please sign in to comment.