Method
VteTerminalspawn_with_fds_async
Declaration [src]
void
vte_terminal_spawn_with_fds_async (
VteTerminal* terminal,
VtePtyFlags pty_flags,
const char* working_directory,
const char* const* argv,
const char* const* envv,
const int* fds,
int n_fds,
const int* map_fds,
int n_map_fds,
GSpawnFlags spawn_flags,
GSpawnChildSetupFunc child_setup,
gpointer child_setup_data,
GDestroyNotify child_setup_data_destroy,
int timeout,
GCancellable* cancellable,
VteTerminalSpawnAsyncCallback callback,
gpointer user_data
)
Description [src]
A convenience function that wraps creating the VtePty
and spawning
the child process on it. See vte_pty_new_sync(), vte_pty_spawn_with_fds_async(),
and vte_pty_spawn_finish()
for more information.
When the operation is finished successfully, callback
will be called
with the child GPid
, and a NULL
GError
. The child PID will already be
watched via vte_terminal_watch_child().
When the operation fails, callback
will be called with a -1 GPid
,
and a non-NULL
GError
containing the error information.
Note that G_SPAWN_STDOUT_TO_DEV_NULL
, G_SPAWN_STDERR_TO_DEV_NULL
,
and G_SPAWN_CHILD_INHERITS_STDIN
are not supported in spawn_flags
, since
stdin, stdout and stderr of the child process will always be connected to
the PTY.
If fds
is not NULL
, the child process will map the file descriptors from
fds
according to map_fds
; n_map_fds
must be less or equal to n_fds
.
This function will take ownership of the file descriptors in fds
;
you must not use or close them after this call.
Note that all open file descriptors apart from those mapped as above will be closed in the child. (If you want to keep some other file descriptor open for use in the child process, you need to use a child setup function that unsets the FD_CLOEXEC flag on that file descriptor manually.)
Beginning with 0.60, and on linux only, and unless VTE_SPAWN_NO_SYSTEMD_SCOPE
is
passed in spawn_flags
, the newly created child process will be moved to its own
systemd user scope; and if VTE_SPAWN_REQUIRE_SYSTEMD_SCOPE
is passed, and creation
of the systemd user scope fails, the whole spawn will fail.
You can override the options used for the systemd user scope by
providing a systemd override file for ‘vte-spawn-.scope’ unit. See man:systemd.unit(5)
for further information.
Note that if terminal
has been destroyed before the operation is called,
callback
will be called with a NULL
terminal
; you must not do anything
in the callback besides freeing any resources associated with user_data
,
but taking care not to access the now-destroyed VteTerminal
. Note that
in this case, if spawning was successful, the child process will be aborted automatically.
Beginning with 0.52, sets PWD to working_directory
in order to preserve symlink components.
The caller should also make sure that symlinks were preserved while constructing the value of working_directory
,
e.g. by using vte_terminal_get_current_directory_uri(), g_get_current_dir()
or get_current_dir_name().
Available since: | 0.62 |
Parameters
pty_flags |
VtePtyFlags |
Flags from |
|
working_directory |
const char* |
The name of a directory the command should start
in, or |
|
The argument can be NULL . | |
The data is owned by the caller of the function. | |
The value is a NUL terminated UTF-8 string. | |
argv |
An array of filename |
Child’s argument vector. |
|
The array must be NULL -terminated. | |
The data is owned by the caller of the function. | |
Each element is a file system path, using the OS encoding. | |
envv |
An array of filename |
A list of environment
variables to be added to the environment before starting the process, or |
|
The argument can be NULL . | |
The array must be NULL -terminated. | |
The data is owned by the caller of the function. | |
Each element is a file system path, using the OS encoding. | |
fds |
An array of int |
An array of file descriptors, or |
|
The argument can be NULL . | |
The length of the array is specified in the n_fds argument. | |
The data is owned by the caller of the function. | |
n_fds |
int |
The number of file descriptors in |
|
map_fds |
An array of int |
An array of integers, or |
|
The argument can be NULL . | |
The length of the array is specified in the n_map_fds argument. | |
The data is owned by the caller of the function. | |
n_map_fds |
int |
The number of elements in |
|
spawn_flags |
GSpawnFlags |
Flags from |
|
child_setup |
GSpawnChildSetupFunc |
An extra child setup function to run in the child just before exec(), or |
|
The argument can be NULL . | |
child_setup_data |
gpointer |
User data for |
|
The argument can be NULL . | |
The data is owned by the caller of the function. | |
child_setup_data_destroy |
GDestroyNotify |
A |
|
The argument can be NULL . | |
timeout |
int |
A timeout value in ms, -1 for the default timeout, or G_MAXINT to wait indefinitely. |
|
cancellable |
GCancellable |
A |
|
The argument can be NULL . | |
The data is owned by the caller of the function. | |
callback |
VteTerminalSpawnAsyncCallback |
A |
|
The argument can be NULL . | |
user_data |
gpointer |
User data for |
|
The argument can be NULL . | |
The data is owned by the caller of the function. |