mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8208715: Conversion of milliseconds to nanoseconds in UNIXProcess contains bug
Reviewed-by: martin
This commit is contained in:
parent
8cf153fbd5
commit
63b1edb7b7
4 changed files with 42 additions and 7 deletions
|
@ -497,10 +497,14 @@ final class ProcessImpl extends Process {
|
|||
if (getExitCodeProcess(handle) != STILL_ACTIVE) return true;
|
||||
if (timeout <= 0) return false;
|
||||
|
||||
long deadline = System.nanoTime() + remainingNanos ;
|
||||
long deadline = System.nanoTime() + remainingNanos;
|
||||
do {
|
||||
// Round up to next millisecond
|
||||
long msTimeout = TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L);
|
||||
if (msTimeout < 0) {
|
||||
// if wraps around then wait a long while
|
||||
msTimeout = Integer.MAX_VALUE;
|
||||
}
|
||||
waitForTimeoutInterruptibly(handle, msTimeout);
|
||||
if (Thread.interrupted())
|
||||
throw new InterruptedException();
|
||||
|
@ -514,7 +518,7 @@ final class ProcessImpl extends Process {
|
|||
}
|
||||
|
||||
private static native void waitForTimeoutInterruptibly(
|
||||
long handle, long timeout);
|
||||
long handle, long timeoutMillis);
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue