class ProcessBuilder
Defined at line 23 of file ../../src/lib/process/process_builder.h
Creates a process step-by-step.
For most use cases, |fdio_spawn| and |fdio_spawn_etc| are better choices for
creating processes. However, if you need to manipulate the process after it
has been created but before it has been started, you might want to use this
class.
Public Methods
void ProcessBuilder (const ProcessBuilder & )
Defined at line 34 of file ../../src/lib/process/process_builder.h
ProcessBuilder & operator= (const ProcessBuilder & )
Defined at line 35 of file ../../src/lib/process/process_builder.h
void ProcessBuilder (fidl::UnownedClientEnd<fuchsia_io::Directory> svc_dir)
Creates a process builder that uses the |fuchsia.process.Launcher| service.
The process is created in zx_job_default().
Defined at line 47 of file ../../src/lib/process/process_builder.cc
void ProcessBuilder (zx::job job, fidl::UnownedClientEnd<fuchsia_io::Directory> svc_dir)
Creates a process builder that will build a process in the given |job|.
Defined at line 54 of file ../../src/lib/process/process_builder.cc
void ~ProcessBuilder ()
Defined at line 59 of file ../../src/lib/process/process_builder.cc
void LoadVMO (zx::vmo executable)
Use |executable| as the executable for the process. The calling code is
responsible for setting the correct loader service via AddHandle().
Defined at line 61 of file ../../src/lib/process/process_builder.cc
zx_status_t LoadPath (const std::string & path)
Load the executable for the process from the given |path|.
Defined at line 65 of file ../../src/lib/process/process_builder.cc
const fuchsia_process::ProcessStartData & data ()
Information about the process prior to start.
Valid only between |Prepare| and |Start|.
Defined at line 124 of file ../../src/lib/process/process_builder.h
zx_status_t AddArgs (const std::vector<std::string> & argv)
Append arguments to the argument list for the process.
Safe to call multiple times.
Defined at line 147 of file ../../src/lib/process/process_builder.cc
void AddHandle (uint32_t id, zx::handle handle)
Adds the given handle to the handle list for the process.
Safe to call multiple times.
Defined at line 165 of file ../../src/lib/process/process_builder.cc
void AddHandles (std::vector<fuchsia_process::HandleInfo> handles)
Adds the given handles to the handle list for the process.
Safe to call multiple times.
Defined at line 169 of file ../../src/lib/process/process_builder.cc
void SetDefaultJob (zx::job job)
Provide |job| to the process as PA_JOB_DEFAULT.
By default, the created process will use this job when creating more
processes.
Does not affect in which job the process is created.
Defined at line 174 of file ../../src/lib/process/process_builder.cc
void SetName (std::string name)
Set a name for the process.
The name purely descriptive and used in process listing and other
diagnostic tools. The name doesn't need to correspond to the path.
If |AddArgs| is called with a non-empty vector, the name for the process
will be taken from |argv[0]| the first time |AddArgs| is called. You can
call this function either before or after |AddArgs| to override the name.
If you never call |AddArgs| with a non-empty vector, you will need to call
this function to set a name for the process.
Defined at line 178 of file ../../src/lib/process/process_builder.cc
zx_status_t CloneJob ()
Passes the job in which the process will be created as the |PA_JOB_DEFAULT|
for the created process.
Defaults to zx_job_default() unless you passed a job explicitly when
constructing this object.
Defined at line 180 of file ../../src/lib/process/process_builder.cc
zx_status_t CloneNamespace ()
Clone the FDIO namespace for this process as the namespace for the created
process.
Defined at line 198 of file ../../src/lib/process/process_builder.cc
void CloneStdio ()
Clone the STDIO for this process as the namespace for the created process.
If any of stdin, stdout, or stderr are closed (or otherwise not clonable),
they are ignored.
Defined at line 215 of file ../../src/lib/process/process_builder.cc
zx_status_t CloneEnvironment ()
Clone the environ for this process as the environ for the created process.
Defined at line 222 of file ../../src/lib/process/process_builder.cc
zx_status_t CloneAll ()
Calls |CloneJob|, |CloneLdsvc|, |CloneNamespace|, |CloneStdio|, and
|CloneEnvironment|.
Defined at line 234 of file ../../src/lib/process/process_builder.cc
zx_status_t CloneFileDescriptor (int local_fd, int target_fd)
Clone the local file descriptor |local_fd| as the file descriptor
|target_fd| in the created process.
Defined at line 248 of file ../../src/lib/process/process_builder.cc
zx_status_t Prepare (std::string * error_message)
Create the process.
Upon success, the process is created but not started. At this point, the
process can be inspected and manipulated using |data|.
|error_message| is optional.
Defined at line 258 of file ../../src/lib/process/process_builder.cc
zx_status_t Start (zx::process * process_out)
Actually start the process.
Only valid after |Prepare| has been called successfully.
Defined at line 283 of file ../../src/lib/process/process_builder.cc