< prev index next >

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

Print this page

609             }
610         }
611 
612         @Override
613         public void close() throws IOException {
614             // BufferedInputStream#close() is not synchronized unlike most other
615             // methods. Synchronizing helps avoid race with processExited().
616             synchronized (closeLock) {
617                 super.close();
618             }
619         }
620     }
621 
622     /**
623      * A buffered output stream for a subprocess pipe file descriptor
624      * that allows the underlying file descriptor to be reclaimed when
625      * the process exits, via the processExited hook.
626      */
627     private static class ProcessPipeOutputStream extends BufferedOutputStream {
628         ProcessPipeOutputStream(int fd) {
629             super(new FileOutputStream(newFileDescriptor(fd)));
630         }
631 
632         /** Called by the process reaper thread when the process exits. */
633         synchronized void processExited() {
634             OutputStream out = this.out;
635             if (out != null) {
636                 try {
637                     out.close();
638                 } catch (IOException ignored) {
639                     // We know of no reason to get an IOException, but if
640                     // we do, there's nothing else to do but carry on.
641                 }
642                 this.out = ProcessBuilder.NullOutputStream.INSTANCE;
643             }
644         }
645     }
646 
647     /**
648      * A buffered input stream for a subprocess pipe file descriptor
649      * that allows the underlying file descriptor to be reclaimed when

609             }
610         }
611 
612         @Override
613         public void close() throws IOException {
614             // BufferedInputStream#close() is not synchronized unlike most other
615             // methods. Synchronizing helps avoid race with processExited().
616             synchronized (closeLock) {
617                 super.close();
618             }
619         }
620     }
621 
622     /**
623      * A buffered output stream for a subprocess pipe file descriptor
624      * that allows the underlying file descriptor to be reclaimed when
625      * the process exits, via the processExited hook.
626      */
627     private static class ProcessPipeOutputStream extends BufferedOutputStream {
628         ProcessPipeOutputStream(int fd) {
629             super(new PipeOutputStream(newFileDescriptor(fd)));
630         }
631 
632         /** Called by the process reaper thread when the process exits. */
633         synchronized void processExited() {
634             OutputStream out = this.out;
635             if (out != null) {
636                 try {
637                     out.close();
638                 } catch (IOException ignored) {
639                     // We know of no reason to get an IOException, but if
640                     // we do, there's nothing else to do but carry on.
641                 }
642                 this.out = ProcessBuilder.NullOutputStream.INSTANCE;
643             }
644         }
645     }
646 
647     /**
648      * A buffered input stream for a subprocess pipe file descriptor
649      * that allows the underlying file descriptor to be reclaimed when
< prev index next >