spawn_with_fds_async


Description:

[ Version ( since = "0.62" ) ]
public void spawn_with_fds_async (PtyFlags pty_flags, string? working_directory, string[] argv, string[]? envv, int[]? fds, int[]? map_fds, SpawnFlags spawn_flags, int timeout, Cancellable? cancellable)

A convenience function that wraps creating the Pty and spawning the child process on it.

See Pty.sync, spawn_with_fds_async, and spawn_async.end for more information.

When the operation is finished successfully, callback will be called with the child Pid, and a null Error. The child PID will already be watched via watch_child.

When the operation fails, callback will be called with a -1 Pid, and a non-%NULL Error containing the error information.

Note that STDOUT_TO_DEV_NULL, STDERR_TO_DEV_NULL, and 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 ; map_fds.length must be less or equal to fds.length. 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 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 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 this has been destroyed before the operation is called, callback will be called with a null this; 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 Terminal. 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 get_current_directory_uri, get_current_dir or get_current_dir_name.

Parameters:

this

a Terminal

pty_flags

flags from PtyFlags

working_directory

the name of a directory the command should start in, or null to use the current working directory

argv

child's argument vector

envv

a list of environment variables to be added to the environment before starting the process, or null

fds

an array of file descriptors, or null

map_fds

an array of integers, or null

spawn_flags

flags from SpawnFlags

timeout

a timeout value in ms, -1 for the default timeout, or G_MAXINT to wait indefinitely

cancellable

a Cancellable, or null

callback

a TerminalSpawnAsyncCallback, or null

child_setup

an extra child setup function to run in the child just before exec, or null

child_setup_data

user data for child_setup, or null

child_setup_data_destroy

a DestroyNotify for child_setup_data, or null

n_fds

the number of file descriptors in fds, or 0 if fds is null

n_map_fds

the number of elements in map_fds, or 0 if map_fds is null

user_data

user data for callback, or null