std.process 包
功能介绍
process 包主要提供 Process 进程操作接口,主要包括进程创建,标准流获取,进程等待,进程信息查询等。
本包提供多平台统一操控能力,目前支持 Linux 平台,macOS 平台,Windows 平台与 HarmonyOS 平台。
API 列表
类
| 类名 | 功能 | 
|---|---|
| CurrentProcess | 此类为当前进程类,继承 Process 类,提供对当前进程操作相关功能。 | 
| Process | 此类为进程类,提供进程操作相关功能。 | 
| SubProcess | 此类为子进程类,继承 Process 类,提供对子进程操作相关功能。 | 
枚举
| 枚举名 | 功能 | 
|---|---|
| ProcessRedirect | 用于在创建进程时设置子进程标准流的重定向模式。 | 
异常类
| 异常类名 | 功能 | 
|---|---|
| ProcessException | process 包的异常类。 | 
兼容性说明
class Process
| 成员 | 支持平台 | 
|---|---|
| current | Linux Windows macOS HarmonyOS | 
| pid | Linux Windows macOS HarmonyOS | 
| name | Linux Windows macOS HarmonyOS | 
| command | Linux Windows macOS HarmonyOS | 
| arguments | Linux macOS HarmonyOS | 
| commandLine | Linux macOS HarmonyOS | 
| workingDirectory | Linux macOS HarmonyOS | 
| environment | Linux HarmonyOS | 
| of(Int64) | Linux Windows macOS HarmonyOS | 
| start(String, Array | Linux Windows macOS HarmonyOS | 
| run(String, Array | Linux Windows macOS HarmonyOS | 
| runOutput(String, Array | Linux Windows macOS HarmonyOS | 
| terminate(Bool) | Linux Windows macOS HarmonyOS | 
class CurrentProcss
| 成员 | 支持平台 | 
|---|---|
| arguments | Linux Windows macOS HarmonyOS | 
| homeDirectory | Linux Windows macOS | 
| tempDirectory | Linux Windows macOS | 
| stdIn | Linux Windows macOS HarmonyOS | 
| stdOut | Linux Windows macOS HarmonyOS | 
| stdErr | Linux Windows macOS HarmonyOS | 
| atExit(() -> Unit) | Linux Windows macOS HarmonyOS | 
| exit(Int64) | Linux Windows macOS HarmonyOS | 
| getEnv(String) | Linux Windows macOS HarmonyOS | 
| removeEnv(String) | Linux Windows macOS HarmonyOS | 
| setEnv(String, String) | Linux Windows macOS HarmonyOS | 
class SubProcess
| 成员 | 支持平台 | 
|---|---|
| stdIn | Linux Windows macOS HarmonyOS | 
| stdOut | Linux Windows macOS HarmonyOS | 
| stdErr | Linux Windows macOS HarmonyOS | 
| wait(Duration) | Linux Windows macOS HarmonyOS | 
| waitOutput() | Linux Windows macOS HarmonyOS |