< prev index next >

src/java.base/share/classes/java/lang/Process.java

Print this page
*** 23,10 ***
--- 23,11 ---
   * questions.
   */
  
  package java.lang;
  
+ import jdk.internal.misc.Blocker;
  import jdk.internal.util.StaticProperty;
  
  import java.io.*;
  import java.lang.ProcessBuilder.Redirect;
  import java.nio.charset.Charset;

*** 837,10 ***
--- 838,79 ---
                  remaining -= nr;
              }
  
              return n - remaining;
          }
+ 
+         @Override
+         public int read() throws IOException {
+             boolean attempted = Blocker.begin();
+             try {
+                 return super.read();
+             } finally {
+                 Blocker.end(attempted);
+             }
+         }
+ 
+         @Override
+         public int read(byte[] b) throws IOException {
+             boolean attempted = Blocker.begin();
+             try {
+                 return super.read(b);
+             } finally {
+                 Blocker.end(attempted);
+             }
+         }
+ 
+         @Override
+         public int read(byte[] b, int off, int len) throws IOException {
+             boolean attempted = Blocker.begin();
+             try {
+                 return super.read(b, off, len);
+             } finally {
+                 Blocker.end(attempted);
+             }
+         }
+     }
+ 
+     /**
+      * An output stream for a subprocess pipe.
+      */
+     static class PipeOutputStream extends FileOutputStream {
+         PipeOutputStream(FileDescriptor fd) {
+             super(fd);
+         }
+ 
+         @Override
+         public void write(int b) throws IOException {
+             boolean attempted = Blocker.begin();
+             try {
+                 super.write(b);
+             } finally {
+                 Blocker.end(attempted);
+             }
+         }
+ 
+         @Override
+         public void write(byte[] b) throws IOException {
+             boolean attempted = Blocker.begin();
+             try {
+                 super.write(b);
+             } finally {
+                 Blocker.end(attempted);
+             }
+         }
+ 
+         @Override
+         public void write(byte[] b, int off, int len) throws IOException {
+             boolean attempted = Blocker.begin();
+             try {
+                 super.write(b, off, len);
+             } finally {
+                 Blocker.end(attempted);
+             }
+         }
      }
  
      /**
       * A nested class to delay looking up the Charset for the native encoding.
       */
< prev index next >