The maximum size for error messages from fdio_spawn_etc() including the null terminator.
The fdio_spawn_etc() function allows the running process to control the file descriptor table in the process being spawned. These values are put into the action
field of fdio_spawn_action_t
to indicate which action is requested and which of the union subfields to use.
Duplicate a descriptor local_fd
into target_fd
in the spawned process. Uses the fd
entry in the fdio_spawn_action_t
union.
Transfer local descriptor local_fd
into target_fd
in the spawned process.
This action will fail if local_fd
is not a valid local_fd
, if local_fd
has been duplicated, if local_fd
is being used in an io operation, or if local_fd
does not support this operation.
From the point of view of the calling process, the local_fd
will appear to have been closed, regardless of whether the fdio_spawn_etc
call succeeds.
Uses the fd
entry in the fdio_spawn_action_t
union.
Add the given entry to the namespace of the spawned process.
If FDIO_SPAWN_CLONE_NAMESPACE
is specified via flags
, the namespace entry is added to the cloned namespace from the calling process.
The namespace entries are added in the order they appear in the action list. If FDIO_SPAWN_CLONE_NAMESPACE
is specified via flags
, the entries from the calling process are added before any entries specified with FDIO_SPAWN_ACTION_ADD_NS_ENTRY
.
The spawned process decides how to process and interpret the namespace entries. Typically, the spawned process with disregard duplicate entries (i.e., the first entry for a given name wins) and will ignore nested entries (e.g., /foo/bar
when /foo
has already been added to the namespace).
To override or replace an entry in the namespace of the calling process, use fdio_ns_export_root
to export the namespace table of the calling process and construct the namespace for the spawned process explicitly using FDIO_SPAWN_ACTION_ADD_NS_ENTRY
.
The given handle will be closed regardless of whether the fdio_spawn_etc
call succeeds.
Uses the ns
entry in the fdio_spawn_action_t
union.
Add the given handle to the process arguments of the spawned process.
The given handle will be closed regardless of whether the fdio_spawn_etc
call succeeds.
Uses the h
entry in the fdio_spawn_action_t
union.
Sets the name of the spawned process to the given name.
Overrides the default of use the first argument to name the process.
Uses the name
entry in the fdio_spawn_action_t
union.
Shares the given directory by installing it into the namespace of spawned process.
Uses the dir
entry in the fdio_spawn_action_t
union
The fdio_spawn() and fdio_spawn_etc() functions allow some or all of the environment of the running process to be shared with the process being spawned. These macros define bits that can be combined in the flags
parameter.
Provides the spawned process with the job in which the process was created.
The spawned process receives the job using the PA_JOB_DEFAULT
process argument.
Provides the spawned process with the shared library loader resolved via fuchsia.process.Resolver (if resolved), or that which is used by this process.
The shared library loader is passed as PA_LDSVC_LOADER
.
Clones the filesystem namespace into the spawned process.
Clones file descriptors 0, 1, and 2 into the spawned process.
Skips any of these file descriptors that are closed without generating an error.
Clones the environment into the spawned process.
Clones the process-global UTC clock into the spawned process.
Clones all of the above into the spawned process.
Instructs fdio_spawn_etc
which actions to take.
The action to take.
See FDIO_SPAWN_ACTION_*
above. If action
is invalid, the action will be ignored (rather than generate an error).
Spawn a process in the given job.
The program for the process is loaded from the given path
and passed argv
. The aspects of this process' environment indicated by flags
are shared with the process. If the target program begins with #!resolve
then the binary is resolved by url via fuchsia.process.Resolver
.
The argv
array must be terminated with a null pointer.
If job
is ZX_HANDLE_INVALID
, then the process is spawned in zx_job_default()
. Does not take ownership of job
.
Upon success, process_out
will be a handle to the process.
ZX_ERR_NOT_FOUND
: path
cannot be opened.
ZX_ERR_BAD_HANDLE
: path
cannot be opened as an executable VMO.
ZX_ERR_PEER_CLOSED
: Cannot connect to fuchsia.process.Launcher
.
Returns the result of fdio_spawn_vmo() in all other cases.
Spawn a process in the given job.
The binary for the process is loaded from the given path
and passed argv
. The aspects of this process' environment indicated by clone
are shared with the process.
The spawned process is also given environ
as its environment and the given actions
are applied when creating the process.
The argv
array must be terminated with a null pointer.
If non-null, the environ
array must be terminated with a null pointer.
If non-null, the err_msg_out
buffer must have space for FDIO_SPAWN_ERR_MSG_MAX_LENGTH
bytes.
If both FDIO_SPAWN_CLONE_ENVIRON
and environ
are specified, then the spawned process is given environ
as its environment. If both FDIO_SPAWN_CLONE_STDIO
and actions
that target any of fds 0, 1, and 2 are specified, then the actions that target those fds will control their semantics in the spawned process.
If job
is ZX_HANDLE_INVALID
, then the process is spawned in zx_job_default()
. Does not take ownership of job
.
Upon success, process_out
will be a handle to the process. Upon failure, if err_msg_out
is not null, an error message will be we written to err_msg_out
, including a null terminator.
ZX_ERR_NOT_FOUND
: path
cannot be opened.
ZX_ERR_BAD_HANDLE
: path
cannot be opened as an executable VMO.
ZX_ERR_PEER_CLOSED
: Cannot connect to fuchsia.process.Launcher
.
Returns the result of fdio_spawn_vmo() in all other cases.
Spawn a process using the given executable in the given job.
See fdio_spawn_etc() for details. Rather than loading the binary for the process from a path, this function receives the binary as the contents of a vmo.
Always consumes executable_vmo
.
ZX_ERR_INVALID_ARGS
: any supplied action is invalid, or the process name is unset.
ZX_ERR_IO_INVALID
: the recursion limit is hit resolving the executable name.
ZX_ERR_BAD_HANDLE
: executable_vmo
is not a valid handle.
ZX_ERR_WRONG_TYPE
: executable_vmo
is not a VMO handle.
ZX_ERR_ACCESS_DENIED
: executable_vmo
is not readable.
ZX_ERR_OUT_OF_RANGE
: executable_vmo
is smaller than the resolver prefix.
ZX_ERR_PEER_CLOSED
: Cannot connect to fuchsia.process.Launcher
.
ZX_ERR_INTERNAL
: A dependency needed to launch the process was unavailable. Most commonly this indicates a failure attempting to resolve a #!resolve
line using fuchsia.process.Resolver
.
May return other errors.