Weird behavior for "ProcessBuilder.inheritIO()" in IDEA

Answered

Hi,

I've encountered a weird problem when using IDEA, and hope I can get an answer here.

I'm writing a simple program using "ProcessBuilder" to call multiple other tools in the system to do some testing.

And I want to redirect the standard I/O of the subprocesses to the current java process.

So I wrote my original code like below:

public class TestHarness {
public static void main(String[] args) {
try {
runProcess();
} catch (Exception e) {
e.printStackTrace();
}
}

public static void runProcess() throws IOException {
String cmd = "https -h google.com";
List<String> cmdList = Arrays.asList(cmd.split(" "));
ProcessBuilder pb = new ProcessBuilder(cmdList);
Process p = pb.inheritIO().start();
}
}

This program runs as expected in the terminal. But when I ran this program in IDEA, I found the process hung, and no output was printed in stdout.

It seems the problem is due to "inheritIO", but I cannot understand what is happening underneath. Is IDEA doing something with standard I/O?

I tested on JDK8/11/14, all have the problem.

And I've only encountered the problem with this particular executable. The executable "https" can be found here.

0
1 comment

I reproduced the problem and created YouTrack bug request to investigate that: https://youtrack.jetbrains.com/issue/IDEA-258730

0

Please sign in to leave a comment.