authorgravatar for mail@abhinavg.netAbhinav Gupta <mail@abhinavg.net> 2024-05-10 07:05:20-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-05-10 14:05:20+00:00
logfe1b3976064e2d5b08590bf78aa4f4220c757da3
treefbb7deb4270db9ace7852ed1ee93926d44a3440f
parent841bb0a1fd73f71865ec29027a8f6de8ed0efa74
signaturebadge-check Signed by PGP key B5690EEEBB952194

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 {...@@ -31,10 +31,23 @@ pub const ChildProcess = struct {
3131
32 allocator: mem.Allocator,32 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()`.
34 stdin: ?File,37 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()`.
35 stdout: ?File,42 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()`.
36 stderr: ?File,47 stderr: ?File,
3748
49 /// Terminated state of the child process.
50 /// Available after calling `wait()`.
38 term: ?(SpawnError!Term),51 term: ?(SpawnError!Term),
3952
40 argv: []const []const u8,53 argv: []const []const u8,
...@@ -159,10 +172,23 @@ pub const ChildProcess = struct {...@@ -159,10 +172,23 @@ pub const ChildProcess = struct {
159 Unknown: u32,172 Unknown: u32,
160 };173 };
161174
175 /// Behavior of the child process's standard input, output, and error
176 /// streams.
162 pub const StdIo = enum {177 pub const StdIo = enum {
178 /// Inherit the stream from the parent process.
163 Inherit,179 Inherit,
180
181 /// Pass a null stream to the child process.
182 /// This is /dev/null on POSIX and NUL on Windows.
164 Ignore,183 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.
165 Pipe,189 Pipe,
190
191 /// Close the stream after the child process spawns.
166 Close,192 Close,
167 };193 };
168194