Class PosixPipe

java.lang.Object
org.aksw.shellgebra.exec.graph.PipeBase
org.aksw.shellgebra.io.pipe.PosixPipe
All Implemented Interfaces:
Closeable, AutoCloseable

public final class PosixPipe extends PipeBase implements Closeable
Anonymous POSIX pipe with Java stream wrappers and /proc path helper. Linux-only if you use getReadEndProcPath().
  • Method Details

    • open

      public static PosixPipe open() throws IOException
      Create a new anonymous pipe (readFd, writeFd).
      Throws:
      IOException
    • getInputStream

      public InputStream getInputStream()
      Specified by:
      getInputStream in class PipeBase
    • getOutputStream

      public OutputStream getOutputStream()
      Specified by:
      getOutputStream in class PipeBase
    • getReadFd

      public int getReadFd()
    • getWriteFd

      public int getWriteFd()
    • procPath

      public static Path procPath(int fd)
    • getReadFileDescriptor

      public FileDescriptor getReadFileDescriptor()
    • getWriteFileDescriptor

      public FileDescriptor getWriteFileDescriptor()
    • getReadEndProcPath

      public Path getReadEndProcPath()
      Linux-only: path that other processes can open to attach to the pipe read end. Think: cat $(pipe.getReadEndProcPath())
    • getReadEndProcFile

      public File getReadEndProcFile()
    • getWriteEndProcPath

      public Path getWriteEndProcPath()
    • getWriteEndProcFile

      public File getWriteEndProcFile()
    • close

      public void close() throws IOException
      Close both ends of the pipe. We let the Java streams own the close(); they will close the underlying fds.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • isAnonymousProcPipe

      public static boolean isAnonymousProcPipe(Path p) throws IOException
      Throws:
      IOException