std.process

Overview

Provides Process operation APIs for process creation, standard stream obtaining, process waiting, and process information querying.

This package is available on Linux, macOS, Windows, and HarmonyOS.

API List

Functions

NameDescription
executeCreates and runs a subprocess based on input parameters, waits until the subprocess is complete, and returns the exit status of the subprocess.
executeWithOutputCreates and runs a subprocess based on input parameters, waits until the subprocess is complete, and returns the exit status, standard output, and standard error of the subprocess.
findProcessBinds a process instance based on the input process ID.
launchCreates and runs a subprocess based on input parameters and returns a subprocess instance.

Classes

NameDescription
CurrentProcess (deprecated)Specifies the current process class inherited from the Process class and provides functionalities related to operations on the current process.
ProcessSpecifies a process class which provides functionalities related to process operations.
SubProcessSpecifies a subprocess class inherited from the Process class and provides functionalities related to subprocess operations.

Enums

NameDescription
ProcessRedirectSets the redirection mode of the subprocess standard stream when a process is created.

Exceptions

NameDescription
ProcessExceptionSpecifies the exception class of the process package.

Compatibility

class Process

MemberSupported OS
current (deprecated)Linux, Windows, macOS, and HarmonyOS
pidLinux, Windows, macOS, and HarmonyOS
nameLinux, Windows, macOS, and HarmonyOS
commandLinux, Windows, macOS, and HarmonyOS
arguments (deprecated)Linux, macOS, and HarmonyOS
commandLine (deprecated)Linux, macOS, and HarmonyOS
environment (deprecated)Linux and HarmonyOS
workingDirectory (deprecated)Linux, macOS, and HarmonyOS
of(Int64) (deprecated)Linux, Windows, macOS, and HarmonyOS
start(String, Array<String>, Path, Map<String, String>, ProcessRedirect, ProcessRedirect, ProcessRedirect) (deprecated)Linux, Windows, macOS, and HarmonyOS
run(String, Array<String>, Path, Map<String, String>, ProcessRedirect, ProcessRedirect, ProcessRedirect, Duration) (deprecated)Linux, Windows, macOS, and HarmonyOS
runOutput(String, Array<String>, Path, Map<String, String>, ProcessRedirect, ProcessRedirect, ProcessRedirect) (deprecated)Linux, Windows, macOS, and HarmonyOS
terminate(Bool)Linux, Windows, macOS, and HarmonyOS

class CurrentProcss (deprecated)

NOTE

This class will be deprecated in future releases and the functionalities in std.env will be used instead.

MemberSupported OS
argumentsLinux, Windows, macOS, and HarmonyOS
homeDirectoryLinux, Windows, and macOS
tempDirectoryLinux, Windows, and macOS
stdInLinux, Windows, macOS, and HarmonyOS
stdOutLinux, Windows, macOS, and HarmonyOS
stdErrLinux, Windows, macOS, and HarmonyOS
atExit(() -> Unit)Linux, Windows, macOS, and HarmonyOS
exit(Int64)Linux, Windows, macOS, and HarmonyOS
getEnv(String)Linux, Windows, macOS, and HarmonyOS
removeEnv(String)Linux, Windows, macOS, and HarmonyOS
setEnv(String, String)Linux, Windows, macOS, and HarmonyOS

class SubProcess

MemberSupported OS
stdIn (deprecated)Linux, Windows, macOS, and HarmonyOS
stdInPipeLinux, Windows, macOS, and HarmonyOS
stdOut (deprecated)Linux, Windows, macOS, and HarmonyOS
stdOutPipeLinux, Windows, macOS, and HarmonyOS
stdErr (deprecated)Linux, Windows, macOS, and HarmonyOS
stdErrPipeLinux, Windows, macOS, and HarmonyOS
wait(Duration)Linux, Windows, macOS, and HarmonyOS
waitOutput()Linux, Windows, macOS, and HarmonyOS