Sven Wollinger
02/01/2024, 10:54 AMfun exec(command: String, directory: File) {
//logger.debug("exec(command=$command, directory=$directory)")
val process = ProcessBuilder()
.redirectErrorStream(true)
.command(command.split(" "))
.directory(directory)
.start()
process.inputReader().lines().forEach {
println("Log: $it")
}
val result = process.waitFor()
println("Done!")
if(result != 0) throw Exception("Return code: $result")
}
"Done!" runs before the inputReaders log is finished.
I understand its probably async, but isnt waitFor() supposed to..well, wait?Joffrey
02/08/2024, 9:13 AMwaitFor
waits for the end of the process execution. Are you sure the logs aren't finished, though? You don't seem to be printing the error stream of the process, so you might just not see the error