Object - system : Process

This object contains information on a process being created from Ballerina. This is returned from the exec function in the system module.

Methods

Waits for the process to finish its work and exit.
 int|error exitCode = process.waitForExit();
Returns the exit code of the process when it has finished the execution. Error if the process has not exited yet.
 int|error exitCode = process.exitCode();
Destroys the process.
 process.destroy();
Provides a channel (to write into), which is made available as the 'standard input' for the process.
 io:WritableByteChannel output = process.stdin();
Provides a channel (to read from), which is made available as the 'standard output' of the process.
 io:ReadableByteChannel input = process.stdout();
Provides a channel (to read from), which is made available as the 'standard error' of the process.
 io:ReadableByteChannel input = process.stderr();
Pipes the standard output of the current process to the standard input of the given process.
 var x3out = x1.pipe(x2).pipe(x3).stdout();

waitForExit

()

returns int | Error
Waits for the process to finish its work and exit.
 int|error exitCode = process.waitForExit();
  • Return Type

    (int | Error)
  • Returns the exit code for the process or else an Error if a failure occurs

exitCode

()

returns int | Error
Returns the exit code of the process when it has finished the execution. Error if the process has not exited yet.
 int|error exitCode = process.exitCode();
  • Return Type

    (int | Error)
  • Returns the exit code of the process or else an Error if the process hasn't exited yet

destroy

Destroys the process.
 process.destroy();

stdin

()

returns WritableByteChannel
Provides a channel (to write into), which is made available as the 'standard input' for the process.
 io:WritableByteChannel output = process.stdin();
  • Return Type

    (WritableByteChannel)
  • The io:WritableByteChannel, which represents the process's 'standard input'

stdout

()

returns ReadableByteChannel
Provides a channel (to read from), which is made available as the 'standard output' of the process.
 io:ReadableByteChannel input = process.stdout();
  • Return Type

    (ReadableByteChannel)
  • The io:ReadableByteChannel, which represents the process's 'standard output'

stderr

()

returns ReadableByteChannel
Provides a channel (to read from), which is made available as the 'standard error' of the process.
 io:ReadableByteChannel input = process.stderr();
  • Return Type

    (ReadableByteChannel)
  • The io:ReadableByteChannel, which represents the process's 'standard error'

pipe

(Process process)

returns Process
Pipes the standard output of the current process to the standard input of the given process.
 var x3out = x1.pipe(x2).pipe(x3).stdout();

Parameters

  • process Process
  • The process to pipe the data to

  • Return Type

    (Process)
  • The process that is passed to be used to help the chain pipe operations