Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
Ubuntu 9.04, tested with Groovy 1.6.4
I didn't test it on Mac or WIndows.
Description
When 'Process.waitForOrKill' kills the process, killing the process takes some time. (One or two second) If 'Process.exitValue()' is called in this time, an IllegalThreadStateException is thrown. This does not happen always. It's a race condition.
This "test" fails most of the time, for me:
—
Process p = 'sleep 2'.execute()
p.waitForOrKill(1000)
p.exitValue()
—
But this one always works:
—
Process p = 'sleep 2'.execute()
p.waitForOrKill(1000)
p.waitFor()
p.exitValue()
—
I suggest 'Process.waitForOrKill' always calls 'waitFor' after killing the process.
As a kind of "test case", you can use:
—
100.times {
Process p = 'sleep 2'.execute()
p.waitForOrKill(1000)
p.exitValue()
}
—
This fails always for me after one to four loops.
But this one always completes:
—
100.times {
Process p = 'sleep 2'.execute()
p.waitForOrKill(1000)
p.waitFor()
p.exitValue()
}
—