From 886f12dab8338d05589cc3643c42e977cb439bef Mon Sep 17 00:00:00 2001 From: jspspike Date: Tue, 11 Aug 2020 15:27:31 -0500 Subject: [PATCH 1/2] Change open_browser to open browser in child process --- src/terminal/browser.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/terminal/browser.rs b/src/terminal/browser.rs index a8ce5bbba..d4f933a6f 100644 --- a/src/terminal/browser.rs +++ b/src/terminal/browser.rs @@ -1,16 +1,16 @@ use std::process::Command; pub fn open_browser(url: &str) -> Result<(), failure::Error> { - let _output = if cfg!(target_os = "windows") { + if cfg!(target_os = "windows") { let url_escaped = url.replace("&", "^&"); let windows_cmd = format!("start {}", url_escaped); - Command::new("cmd").args(&["/C", &windows_cmd]).output()? + Command::new("cmd").args(&["/C", &windows_cmd]).spawn()?; } else if cfg!(target_os = "linux") { let linux_cmd = format!(r#"xdg-open "{}""#, url); - Command::new("sh").arg("-c").arg(&linux_cmd).output()? + Command::new("sh").arg("-c").arg(&linux_cmd).spawn()?; } else { let mac_cmd = format!(r#"open "{}""#, url); - Command::new("sh").arg("-c").arg(&mac_cmd).output()? + Command::new("sh").arg("-c").arg(&mac_cmd).spawn()?; }; Ok(()) From a3656a974541ada6263f1901016342cbfc9fb2aa Mon Sep 17 00:00:00 2001 From: jspspike Date: Tue, 11 Aug 2020 20:26:26 -0500 Subject: [PATCH 2/2] Made stdout go to /dev/null --- src/terminal/browser.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/terminal/browser.rs b/src/terminal/browser.rs index d4f933a6f..77b4a7ddb 100644 --- a/src/terminal/browser.rs +++ b/src/terminal/browser.rs @@ -1,16 +1,27 @@ -use std::process::Command; +use std::process::{Command, Stdio}; pub fn open_browser(url: &str) -> Result<(), failure::Error> { if cfg!(target_os = "windows") { let url_escaped = url.replace("&", "^&"); let windows_cmd = format!("start {}", url_escaped); - Command::new("cmd").args(&["/C", &windows_cmd]).spawn()?; + Command::new("cmd") + .args(&["/C", &windows_cmd]) + .stdout(Stdio::null()) + .spawn()?; } else if cfg!(target_os = "linux") { let linux_cmd = format!(r#"xdg-open "{}""#, url); - Command::new("sh").arg("-c").arg(&linux_cmd).spawn()?; + Command::new("sh") + .arg("-c") + .arg(&linux_cmd) + .stdout(Stdio::null()) + .spawn()?; } else { let mac_cmd = format!(r#"open "{}""#, url); - Command::new("sh").arg("-c").arg(&mac_cmd).spawn()?; + Command::new("sh") + .arg("-c") + .arg(&mac_cmd) + .stdout(Stdio::null()) + .spawn()?; }; Ok(())