std.process

Functionality Overview

The process package primarily provides Process operation interfaces, including process creation, standard stream acquisition, process waiting, process information querying, etc.

This package offers cross-platform unified operation capabilities, currently supporting Linux, macOS, and Windows platforms.

API List

Functions

Function Name Description
execute Creates and runs a child process based on input parameters, waits for the child process to complete, and returns the child process exit status.
executeWithOutput Creates and runs a child process based on input parameters, waits for the child process to complete, and returns the child process exit status, standard output, and standard error.
findProcess Binds a process instance based on the input process ID.
launch Creates and runs a child process based on input parameters, and returns a child process instance.

Classes

Class Name Description
CurrentProcess (deprecated) This class represents the current process, inherits from the Process class, and provides functionality related to current process operations.
Process This class represents a process and provides process operation-related functionality.
SubProcess This class represents a child process, inherits from the Process class, and provides child process operation-related functionality.

Enums

Enum Name Description
ProcessRedirect Used to set the redirection mode of child process standard streams when creating a process.

Exception Classes

Exception Class Name Description
ProcessException The exception class for the process package.

Compatibility Notes

class Process

Member Supported Platforms
current (deprecated) Linux Windows macOS
pid Linux Windows macOS
name Linux Windows macOS
command Linux Windows macOS
arguments (deprecated) Linux macOS
commandLine (deprecated) Linux macOS
environment (deprecated) Linux
workingDirectory (deprecated) Linux macOS
of(Int64) (deprecated) Linux Windows macOS
start(String, Array<String>, Path, Map<String, String>, ProcessRedirect, ProcessRedirect, ProcessRedirect) (deprecated) Linux Windows macOS
run(String, Array<String>, Path, Map<String, String>, ProcessRedirect, ProcessRedirect, ProcessRedirect, Duration) (deprecated) Linux Windows macOS
runOutput(String, Array<String>, Path, Map<String, String>, ProcessRedirect, ProcessRedirect, ProcessRedirect) (deprecated) Linux Windows macOS
terminate(Bool) Linux Windows macOS

class CurrentProcess (deprecated)

Note:

Will be deprecated in future versions. Alternative functionality can be found in std.env.

Member Supported Platforms
arguments Linux Windows macOS
homeDirectory Linux Windows macOS
tempDirectory Linux Windows macOS
stdIn Linux Windows macOS
stdOut Linux Windows macOS
stdErr Linux Windows macOS
atExit(() -> Unit) Linux Windows macOS
exit(Int64) Linux Windows macOS
getEnv(String) Linux Windows macOS
removeEnv(String) Linux Windows macOS
setEnv(String, String) Linux Windows macOS

class SubProcess

Member Supported Platforms
stdIn (deprecated) Linux Windows macOS
stdInPipe Linux Windows macOS
stdOut (deprecated) Linux Windows macOS
stdOutPipe Linux Windows macOS
stdErr (deprecated) Linux Windows macOS
stdErrPipe Linux Windows macOS
wait(Duration) Linux Windows macOS
waitOutput() Linux Windows macOS