问题
Use process = Runtime.getRuntime.exec("other.sh")
to lauch other.sh who exits with 1, however, process.waitFor()
returns with 0. Under Linux RedHat 7.
other.sh just starts another Java process that returns by System.exit(1)
.
I've seen the same problem in https://coderanch.com/t/326568/java/exitValue-returns-inconsistent-values. However, it said that this was a JDK bug in 1.4 and was fixed already. However, I am using JDK 1.8.
I just want to know if there are any other possibilities leading to such weird behavior? Now our customer and we are both frustrated with this incredible issue.
来源:https://stackoverflow.com/questions/56982666/java-process-waitfor-returns-with-inconsistent-value