authorgravatar for mail@abhinavg.netAbhinav Gupta <mail@abhinavg.net> 2024-05-10 07:05:20-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-22 07:03:09-07:00
logd37182383d9e16a123bf89ffdaaa119bbac1d35f
tree55f25c10802aa54e9977e8775a9a9672868314da
parent1216050520008b9cbd5b287a3eb0b2eba4cf5056

ChildProcess: document StdIo behaviors (#17553)

Add some basic documentation for the different ChildProcess.StdIo behaviors and the fields they affect.

1 files changed, 26 insertions(+), 0 deletions(-)

lib/std/child_process.zig+26
......@@ -31,10 +31,23 @@ pub const ChildProcess = struct {
3131
3232 allocator: mem.Allocator,
3333
34 /// The writing end of the child process's standard input pipe.
35 /// Usage requires `stdin_behavior == StdIo.Pipe`.
36 /// Available after calling `spawn()`.
3437 stdin: ?File,
38
39 /// The reading end of the child process's standard output pipe.
40 /// Usage requires `stdout_behavior == StdIo.Pipe`.
41 /// Available after calling `spawn()`.
3542 stdout: ?File,
43
44 /// The reading end of the child process's standard error pipe.
45 /// Usage requires `stderr_behavior == StdIo.Pipe`.
46 /// Available after calling `spawn()`.
3647 stderr: ?File,
3748
49 /// Terminated state of the child process.
50 /// Available after calling `wait()`.
3851 term: ?(SpawnError!Term),
3952
4053 argv: []const []const u8,
......@@ -159,10 +172,23 @@ pub const ChildProcess = struct {
159172 Unknown: u32,
160173 };
161174
175 /// Behavior of the child process's standard input, output, and error
176 /// streams.
162177 pub const StdIo = enum {
178 /// Inherit the stream from the parent process.
163179 Inherit,
180
181 /// Pass a null stream to the child process.
182 /// This is /dev/null on POSIX and NUL on Windows.
164183 Ignore,
184
185 /// Create a pipe for the stream.
186 /// The corresponding field (`stdout`, `stderr`, or `stdin`)
187 /// will be assigned a `File` object that can be used
188 /// to read from or write to the pipe.
165189 Pipe,
190
191 /// Close the stream after the child process spawns.
166192 Close,
167193 };
168194