std.process

功能介绍

process 包主要提供 Process 进程操作接口,主要包括进程创建,标准流获取,进程等待,进程信息查询等。

本包提供多平台统一操控能力,目前支持 Linux 平台,macOS 平台与 Windows 平台。

API 列表

函数

函数名功能
execute根据输入参数创建并运行一个子进程,等待该子进程运行完毕并返回子进程退出状态。
executeWithOutput根据输入参数创建并运行一个子进程,等待该子进程运行完毕并返回子进程退出状态、标准输出和标准错误。
findProcess根据输入进程 id 绑定一个进程实例。
launch根据输入参数创建并运行一个子进程,并返回一个子进程实例。

类名功能
CurrentProcess (deprecated)此类为当前进程类,继承 Process 类,提供对当前进程操作相关功能。
Process此类为进程类,提供进程操作相关功能。
SubProcess此类为子进程类,继承 Process 类,提供对子进程操作相关功能。

枚举

枚举名功能
ProcessRedirect用于在创建进程时设置子进程标准流的重定向模式。

异常类

异常类名功能
ProcessExceptionprocess 包的异常类。

兼容性说明

class Process

class CurrentProcss (deprecated)

注意:

未来版本即将废弃,可在 std.env 中找到代替功能。

成员支持平台
argumentsLinux Windows macOS
homeDirectoryLinux Windows macOS
tempDirectoryLinux Windows macOS
stdInLinux Windows macOS
stdOutLinux Windows macOS
stdErrLinux 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

成员支持平台
stdIn (deprecated)Linux Windows macOS
stdInPipeLinux Windows macOS
stdOut (deprecated)Linux Windows macOS
stdOutPipeLinux Windows macOS
stdErr (deprecated)Linux Windows macOS
stdErrPipeLinux Windows macOS
wait(Duration)Linux Windows macOS
waitOutput()Linux Windows macOS