Packages

c

scala.sys.process

ProcessIO

final class ProcessIO extends AnyRef

This class is used to control the I/O of every scala.sys.process.Process. The functions used to create it will be called with the process streams once it has been started. It might not be necessary to use ProcessIO directly -- scala.sys.process.ProcessBuilder can return the process output to the caller, or use a scala.sys.process.ProcessLogger which avoids direct interaction with a stream. One can even use the factories at BasicIO to create a ProcessIO, or use its helper methods when creating one's own ProcessIO.

When creating a ProcessIO, it is important to close all streams when finished, since the JVM might use system resources to capture the process input and output, and will not release them unless the streams are explicitly closed.

ProcessBuilder will call writeInput, processOutput and processError in separate threads, and if daemonizeThreads is true, they will all be marked as daemon threads.

Source
ProcessIO.scala
Note

Failure to close the passed streams may result in resource leakage.

Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ProcessIO
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new ProcessIO(in: (OutputStream) => Unit, out: (InputStream) => Unit, err: (InputStream) => Unit)
  2. new ProcessIO(writeInput: (OutputStream) => Unit, processOutput: (InputStream) => Unit, processError: (InputStream) => Unit, daemonizeThreads: Boolean)

    writeInput

    Function that will be called with the OutputStream to which all input to the process must be written. This will be called in a newly spawned thread.

    processOutput

    Function that will be called with the InputStream from which all normal output of the process must be read from. This will be called in a newly spawned thread.

    processError

    Function that will be called with the InputStream from which all error output of the process must be read from. This will be called in a newly spawned thread.

    daemonizeThreads

    Indicates whether the newly spawned threads that will run processOutput, processError and writeInput should be marked as daemon threads.

Value Members

  1. val daemonizeThreads: Boolean
  2. def daemonized(): ProcessIO

    Creates a new ProcessIO, with daemonizeThreads true.

  3. val processError: (InputStream) => Unit
  4. val processOutput: (InputStream) => Unit
  5. def withError(process: (InputStream) => Unit): ProcessIO

    Creates a new ProcessIO with a different handler for the error output.

  6. def withInput(write: (OutputStream) => Unit): ProcessIO

    Creates a new ProcessIO with a different handler for the process input.

  7. def withOutput(process: (InputStream) => Unit): ProcessIO

    Creates a new ProcessIO with a different handler for the normal output.

  8. val writeInput: (OutputStream) => Unit