1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Timeout when running commands.

This commit is contained in:
Cedric Beust 2015-11-09 16:24:09 -08:00
parent 21eaa3e414
commit abd768fbc6

View file

@ -4,6 +4,7 @@ import java.io.BufferedReader
import java.io.File
import java.io.InputStream
import java.io.InputStreamReader
import java.util.concurrent.TimeUnit
open class RunCommand(val command: String) {
val defaultSuccess = { output: List<String> -> }
@ -30,8 +31,8 @@ open class RunCommand(val command: String) {
pbEnv.put(it.key, it.value)
}
}
val passed = process.waitFor()//(2, TimeUnit.SECONDS)
val callSucceeded = if (passed == 0) true else false
val callSucceeded = process.waitFor(30, TimeUnit.SECONDS)
// val callSucceeded = if (passed == 0) true else false
if (callSucceeded) {
successCb(fromStream(process.inputStream))
} else {