class ChildProcess

Defined at line 28 of file ../../src/sys/fuzzing/common/child-process.h

Public Methods

bool is_killed ()

Defined at line 33 of file ../../src/sys/fuzzing/common/child-process.h

void ChildProcess (ExecutorPtr executor)

Defined at line 89 of file ../../src/sys/fuzzing/common/child-process.cc

void ~ChildProcess ()

Defined at line 91 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t AddArg (std::string_view arg)

Adds a command line argument for the process. The first |arg| added should be the executable

path relative to the "/pkg" directory, i.e. the same value as might be found in

`program.binary` field in a component manifest.

Returns `ZX_ERR_OUT_OF_RANGE` if unable to add the arg, e.g. due to insufficient space in the

`fuchsia.process.Launcher` message; `ZX_OK` otherwise.

Defined at line 93 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t AddArgs (std::initializer_list<const char *> args)

Adds all of the given |args|.

Returns `ZX_ERR_OUT_OF_RANGE` if unable to add the arg, e.g. due to insufficient space in the

`fuchsia.process.Launcher` message; `ZX_OK` otherwise.

Defined at line 108 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t SetEnvVar (std::string_view name, std::string_view value)

Sets an environment variable. Setting the same variable multiple times updates the value.

Defined at line 121 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t AddStdinPipe ()

Adds a writeable pipe to the standard input of the spawned process.

Returns ZX_ERR_BAD_STATE if called twice without `Reset`.

Defined at line 130 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t AddStdoutPipe ()

Adds a readable pipe from the indicated output file descriptors.

Returns ZX_ERR_BAD_STATE if called twice without `Reset`.

Defined at line 173 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t AddStderrPipe ()

Defined at line 187 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t AddChannel (uint32_t id, zx::channel channel)

Takes a `channel` to be passed as a startup channel to the child process with the given `id`.

Returns `ZX_ERR_OUT_OF_RANGE` if unable to add the channel, e.g. due to insufficient space in

the `fuchsia.process.Launcher` message; `ZX_OK` otherwise.

Defined at line 233 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t AddVmoVdso ()

Adds the vDSO VMO handle

Defined at line 247 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t Spawn ()

Spawns the new child process. Returns an error if a previous process was spawned but has not

been |Kill|ed and |Reset|, or if spawning fails.

Defined at line 284 of file ../../src/sys/fuzzing/common/child-process.cc

bool IsAlive ()

Returns whether the child process has been spawned and is running.

Defined at line 329 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t Duplicate (zx::process * out)

Return a copy of the process.

Defined at line 341 of file ../../src/sys/fuzzing/common/child-process.cc

zx_status_t WriteToStdin (std::string_view line)

Writes a line to process's stdin. Returns an error if the process is not alive of if stdin has

been closed.

Defined at line 345 of file ../../src/sys/fuzzing/common/child-process.cc

ZxPromise<std::string> ReadFromStdout ()

Returns a promise to read from the process's stdout or stderr, respectively. The promise will

read up to a newline or EOF, whichever comes first. The promise will return an error if the

file descriptor is closed or was cloned, and will return |ZX_ERR_STOP| on EOF.

Defined at line 362 of file ../../src/sys/fuzzing/common/child-process.cc

ZxPromise<std::string> ReadFromStderr ()

Defined at line 377 of file ../../src/sys/fuzzing/common/child-process.cc

void CloseStdin ()

Closes the indicated pipe to or from the spawned process. May be called before or after

the process is `Spawn`ed.

Defined at line 392 of file ../../src/sys/fuzzing/common/child-process.cc

void CloseStdout ()
void CloseStderr ()
ZxResult<ProcessStats> GetStats ()

Collect process-related statistics for the child process.

Defined at line 400 of file ../../src/sys/fuzzing/common/child-process.cc

ZxPromise<int64_t> Wait ()

Promises to wait for the spawned process to terminate and return its return code.

Defined at line 408 of file ../../src/sys/fuzzing/common/child-process.cc

ZxPromise<> Kill ()

Returns a promise that kills the spawned process and waits for it to fully terminate. This

leaves the process in a "killed" state; it must be |Reset| before it can be reused.

Defined at line 436 of file ../../src/sys/fuzzing/common/child-process.cc

void Reset ()

Returns this object to an initial state, from which |Spawn| can be called again. This

effectively kills the process, but does not wait for it to fully terminate. Callers should

prefer to |Kill| and then |Reset|. |AddArgs|, |SetFdAction|, and/or |SetChannels| will need to

be called again before respawning.

Defined at line 475 of file ../../src/sys/fuzzing/common/child-process.cc