Skip to content

Commit 97bd5a2

Browse files
author
pepc84
committed
bestCppStd: add 3s timeout to prevent hang on stdin
1 parent e99cb89 commit 97bd5a2

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

mode/CppMode.jar

133 Bytes
Binary file not shown.

src/java/CppBuild.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3043,8 +3043,10 @@ static String bestCppStd(String gpp) {
30433043
pb.redirectErrorStream(true);
30443044
Process proc = pb.start();
30453045
proc.getOutputStream().close();
3046+
// 3 second timeout -- if g++ hangs on stdin, skip this std
3047+
boolean finished = proc.waitFor(3, java.util.concurrent.TimeUnit.SECONDS);
3048+
if (!finished) { proc.destroyForcibly(); continue; }
30463049
String out = new String(proc.getInputStream().readAllBytes());
3047-
proc.waitFor();
30483050
if (!out.contains("unrecognized") && !out.contains("invalid argument") && !out.contains("note: use")) {
30493051
return std;
30503052
}

0 commit comments

Comments
 (0)