Hey, i hope this is an ok-channel for this, im hav...
# general-advice
s
Hey, i hope this is an ok-channel for this, im having an issue with ProcessBuilder.
Copy code
fun 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?
j
Yes,
waitFor
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