Skip to content

Commit

Permalink
Fix hang in windows when javaws is launched outside the console.
Browse files Browse the repository at this point in the history
See issue 273.
  • Loading branch information
lherschi committed Jun 18, 2019
1 parent 175a14f commit a0725c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 13 additions & 4 deletions launchers/rust-launcher/src/os_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ pub fn create_java_cmd(os: &Os,jre_dir: &std::path::PathBuf, args: &Vec<String>)

fn spawn_java_process(os: &Os, jre_dir: &std::path::PathBuf, args: &Vec<String>) -> std::process::Child {
let mut cmd = create_java_cmd(os, jre_dir, args);
cmd.stdin(std::process::Stdio::inherit());
cmd.stdout(std::process::Stdio::inherit());
cmd.stderr(std::process::Stdio::inherit());
if os.inside_console() {
cmd.stdin(std::process::Stdio::inherit());
cmd.stdout(std::process::Stdio::inherit());
cmd.stderr(std::process::Stdio::inherit());
} else {
cmd.stdin(std::process::Stdio::null());
cmd.stdout(std::process::Stdio::null());
cmd.stderr(std::process::Stdio::null());
}
let res = cmd.spawn();
match res {
Ok(child) => child,
Expand Down Expand Up @@ -61,7 +67,6 @@ pub trait Os {
fn get_classpath_separator(&self) -> char;
fn get_exec_suffixes(&self) -> &'static [&'static str];
fn is_verbose(&self) -> bool;
#[cfg(windows)]
fn inside_console(&self) -> bool;
}

Expand Down Expand Up @@ -116,6 +121,10 @@ impl Os for Linux {
return self.verbose;
}

fn inside_console(&self) -> bool {
return true;
}

fn log(&self, s: &str) {
log_helper::log_impl(2,self, s);
}
Expand Down
1 change: 0 additions & 1 deletion launchers/rust-launcher/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ pub mod tests_utils {
return true;
}

#[cfg(windows)]
fn inside_console(&self) -> bool {
return true;
}
Expand Down

0 comments on commit a0725c4

Please sign in to comment.