< prev index next >

src/windows/classes/java/lang/ProcessImpl.java

Print this page
rev 13659 : 8208715: Conversion of milliseconds to nanoseconds in UNIXProcess contains bug

*** 1,7 **** /* ! * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 460,474 **** { if (getExitCodeProcess(handle) != STILL_ACTIVE) return true; if (timeout <= 0) return false; long remainingNanos = unit.toNanos(timeout); ! long deadline = System.nanoTime() + remainingNanos ; do { // Round up to next millisecond long msTimeout = TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L); waitForTimeoutInterruptibly(handle, msTimeout); if (Thread.interrupted()) throw new InterruptedException(); if (getExitCodeProcess(handle) != STILL_ACTIVE) { return true; --- 460,478 ---- { if (getExitCodeProcess(handle) != STILL_ACTIVE) return true; if (timeout <= 0) return false; long remainingNanos = unit.toNanos(timeout); ! 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(); if (getExitCodeProcess(handle) != STILL_ACTIVE) { return true;
*** 478,488 **** return (getExitCodeProcess(handle) != STILL_ACTIVE); } private static native void waitForTimeoutInterruptibly( ! long handle, long timeout); public void destroy() { terminateProcess(handle); } @Override public Process destroyForcibly() { --- 482,492 ---- return (getExitCodeProcess(handle) != STILL_ACTIVE); } private static native void waitForTimeoutInterruptibly( ! long handle, long timeoutMillis); public void destroy() { terminateProcess(handle); } @Override public Process destroyForcibly() {
< prev index next >