< prev index next >

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

Print this page
*** 45,10 ***
--- 45,11 ---
  import java.util.regex.Pattern;
  
  import jdk.internal.access.JavaIOFileDescriptorAccess;
  import jdk.internal.access.SharedSecrets;
  import jdk.internal.ref.CleanerFactory;
+ import jdk.internal.misc.Blocker;
  import sun.security.action.GetBooleanAction;
  import sun.security.action.GetPropertyAction;
  
  /* This class is for the exclusive use of ProcessBuilder.start() to
   * create new processes.

*** 556,11 ***
          return exitCode;
      }
      private static native int getExitCodeProcess(long handle);
  
      public int waitFor() throws InterruptedException {
!         waitForInterruptibly(handle);
          if (Thread.interrupted())
              throw new InterruptedException();
          return exitValue();
      }
  
--- 557,15 ---
          return exitCode;
      }
      private static native int getExitCodeProcess(long handle);
  
      public int waitFor() throws InterruptedException {
!         if (Thread.currentThread().isVirtual()) {
+             Blocker.managedBlock(() -> waitForInterruptibly(handle));
+         } else {
+             waitForInterruptibly(handle);
+         }
          if (Thread.interrupted())
              throw new InterruptedException();
          return exitValue();
      }
  

*** 580,11 ***
              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;
              }
--- 585,16 ---
              long msTimeout = TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L);
              if (msTimeout < 0) {
                  // if wraps around then wait a long while
                  msTimeout = Integer.MAX_VALUE;
              }
!             if (Thread.currentThread().isVirtual()) {
+                 long millis = msTimeout;
+                 Blocker.managedBlock(() -> waitForTimeoutInterruptibly(handle, millis));
+             } else {
+                 waitForTimeoutInterruptibly(handle, msTimeout);
+             }
              if (Thread.interrupted())
                  throw new InterruptedException();
              if (getExitCodeProcess(handle) != STILL_ACTIVE) {
                  return true;
              }
< prev index next >