diff options
| author | Abhinav Gupta <mail@abhinavg.net> | 2024-05-10 07:05:20 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-10 14:05:20 +0000 |
| commit | fe1b3976064e2d5b08590bf78aa4f4220c757da3 (patch) | |
| tree | fbb7deb4270db9ace7852ed1ee93926d44a3440f /lib/std | |
| parent | 841bb0a1fd73f71865ec29027a8f6de8ed0efa74 (diff) | |
| download | zig-fe1b3976064e2d5b08590bf78aa4f4220c757da3.tar.gz zig-fe1b3976064e2d5b08590bf78aa4f4220c757da3.zip | |
ChildProcess: document StdIo behaviors (#17553)
Add some basic documentation for the different ChildProcess.StdIo
behaviors and the fields they affect.
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/child_process.zig | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index e6069aec8e..dfa8d65eff 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -31,10 +31,23 @@ pub const ChildProcess = struct { allocator: mem.Allocator, + /// The writing end of the child process's standard input pipe. + /// Usage requires `stdin_behavior == StdIo.Pipe`. + /// Available after calling `spawn()`. stdin: ?File, + + /// The reading end of the child process's standard output pipe. + /// Usage requires `stdout_behavior == StdIo.Pipe`. + /// Available after calling `spawn()`. stdout: ?File, + + /// The reading end of the child process's standard error pipe. + /// Usage requires `stderr_behavior == StdIo.Pipe`. + /// Available after calling `spawn()`. stderr: ?File, + /// Terminated state of the child process. + /// Available after calling `wait()`. term: ?(SpawnError!Term), argv: []const []const u8, @@ -159,10 +172,23 @@ pub const ChildProcess = struct { Unknown: u32, }; + /// Behavior of the child process's standard input, output, and error + /// streams. pub const StdIo = enum { + /// Inherit the stream from the parent process. Inherit, + + /// Pass a null stream to the child process. + /// This is /dev/null on POSIX and NUL on Windows. Ignore, + + /// Create a pipe for the stream. + /// The corresponding field (`stdout`, `stderr`, or `stdin`) + /// will be assigned a `File` object that can be used + /// to read from or write to the pipe. Pipe, + + /// Close the stream after the child process spawns. Close, }; |
