std.os.process Package

Function Description

The os.process package provides process operation interfaces, including process creation, standard stream obtaining, process waiting, and process information query.

This package provides unified control capabilities for multiple platforms, including Linux, macOS, Windows, and HarmonyOS.

API List

Class

NameDescription
CurrentProcessSpecifies the current process class inherited from the Process class and providing functions related to operations on the current process.
ProcessSpecifies a process class which provides functions related to process operations.
SubProcessSpecifies a subprocess class inherited from the Process class and providing functions related to subprocess operations.

Enumeration

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

Exception Class

NameDescription
ProcessExceptionSpecifies an exception class of the os.process package.

Compatibility

class Process

MemberSupported on
currentLinux, Windows, macOS, and HarmonyOS
pidLinux, Windows, macOS, and HarmonyOS
nameLinux, Windows, macOS, and HarmonyOS
commandLinux, Windows, macOS, and HarmonyOS
argumentsLinux, macOS, and HarmonyOS
commandLineLinux, macOS, and HarmonyOS
workingDirectoryLinux, macOS, and HarmonyOS
environmentLinux and HarmonyOS
of(Int64)Linux, Windows, macOS, and HarmonyOS
start(String, Array, Path, Map<String, String>, ProcessRedirect, ProcessRedirect, ProcessRedirect)Linux, Windows, macOS, and HarmonyOS
run(String, Array, Path, Map<String, String>, ProcessRedirect, ProcessRedirect, ProcessRedirect, Duration)Linux, Windows, macOS, and HarmonyOS
runOutput(String, Array, Path, Map<String, String>, ProcessRedirect, ProcessRedirect, ProcessRedirect)Linux, Windows, macOS, and HarmonyOS
terminate(Bool)Linux, Windows, macOS, and HarmonyOS

class CurrentProcss

MemberSupported on
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

class SubProcess

MemberSupported on
stdInLinux, Windows, macOS, and HarmonyOS
stdOutLinux, Windows, macOS, and HarmonyOS
stdErrLinux, Windows, macOS, and HarmonyOS
wait(Duration)Linux, Windows, macOS, and HarmonyOS
waitOutput()Linux, Windows, macOS, and HarmonyOS