Dart API Referencedart:ioProcess

Process Class

Process is used to start new processes using the static start and run methods.

Static Methods

Code Future<ProcessResult> run(String executable, List<String> arguments, [ProcessOptions options]) #

Starts a process and runs it non-interactively to completion. The process run is executable with the specified arguments.

An optional ProcessOptions object can be passed to specify options other than the executable and the arguments.

Returns a Future<ProcessResult> that completes with the result of running the process, i.e., exit code, standard out and standard in.

static Future<ProcessResult> run(String executable,
                                 List<String> arguments,
                                 [ProcessOptions options]) {
  return _Process.run(executable, arguments, options);
}

Code Process start(String executable, List<String> arguments, [ProcessOptions options]) #

Starts a process running the executable with the specified arguments. Returns a Process instance that can be used to interact with the process.

An optional ProcessOptions object can be passed to specify options other than the executable and the arguments.

When the process has been successfully started onStart is called on the returned Process object. If the process fails to start onError is called on the returned Process object.

No data can be written to the process stdin and the process cannot be closed nor killed before onStart has been invoked.

static Process start(String executable,
                     List<String> arguments,
                     [ProcessOptions options]) {
  return _Process.start(executable, arguments, options);
}

Methods

Code void close() #

Terminates the streams of a process. close must be called on a process to free the system resources associated with it if not all data on the stdout and stderr streams have been read. Usually, close should be called in onExit, but care must be taken to actually wait on the stderr and stdout streams to close if all data is required. Once a process has been closed it can no longer be killed and onExit is detached so the application is not notified of process termination.

abstract void close();

Code void kill([ProcessSignal signal]) #

On Windows, kill kills the process, ignoring the signal flag. On Posix systems, kill sends signal to the process. Depending on the signal giving, it'll have different meanings. The default signal to send is ProcessSignal.SIGTERM. When the process terminates as a result of calling [kill] [onExit] is called. If the kill operation fails, onError is called.

abstract void kill([ProcessSignal signal]);

Code void set onError(void callback(e)) #

Set an error handler which gets invoked if an operation on the process fails.

abstract void set onError(void callback(e));

Code void set onExit(void callback(int exitCode)) #

Sets an exit handler which gets invoked when the process terminates.

Throws an UnsupportedOperationException if the process is non-interactive.

abstract void set onExit(void callback(int exitCode));

Code void set onStart(void callback()) #

Set the start handler which gets invoked when the process is successfully started.

abstract void set onStart(void callback());

Code InputStream get stderr() #

Returns an input stream of the process stderr.

Throws an UnsupportedOperationException if the process is non-interactive.

abstract InputStream get stderr();

Code OutputStream get stdin() #

Returns an output stream to the process stdin.

Throws an UnsupportedOperationException if the process is non-interactive.

abstract OutputStream get stdin();

Code InputStream get stdout() #

Returns an input stream of the process stdout.

Throws an UnsupportedOperationException if the process is non-interactive.

abstract InputStream get stdout();