Terminal.spawnWithFdsAsync

A convenience function that wraps creating the #VtePty and spawning the child process on it. See vte.pty.Pty.newSync, vte.pty.Pty.spawnWithFdsAsync, and vte.pty.Pty.spawnFinish 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.Terminal.watchChild.

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.Terminal.getCurrentDirectoryUri, glib.global.getCurrentDir or get_current_dir_name().

Parameters

ptyFlags vte.types.PtyFlags

flags from #VtePtyFlags

workingDirectory string

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

argv string[]

child's argument vector

envv string[]

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

fds int[]

an array of file descriptors, or null

mapFds int[]

an array of integers, or null

spawnFlags glib.types.SpawnFlags

flags from #GSpawnFlags

childSetup glib.types.SpawnChildSetupFunc

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

timeout int

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

cancellable gio.cancellable.Cancellable

a #GCancellable, or null

callback vte.types.TerminalSpawnAsyncCallback

a #VteTerminalSpawnAsyncCallback, or null