### Method

# Vte Terminal spawn_with_fds_async

since: 0.62

#### 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`

  Type: `VtePtyFlags`

  Flags from `VtePtyFlags`.

`working_directory`

  Type: `const char*`

  The name of a directory the command should start in, or `NULL` to use the current working directory.

  The argument can be `NULL`.
  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`argv`

  Type: An array of `filename`

  Child’s argument vector.

  The array must be `NULL`-terminated.
  The data is owned by the caller of the method.
  Each element is a platform-native string, using the preferred OS encoding on Unix and UTF-8 on Windows.

`envv`

  Type: An array of `filename`

  A list of environment variables to be added to the environment before starting the process, or `NULL`.

  The argument can be `NULL`.
  The array must be `NULL`-terminated.
  The data is owned by the caller of the method.
  Each element is a platform-native string, using the preferred OS encoding on Unix and UTF-8 on Windows.

`fds`

  Type: An array of `int`

  An array of file descriptors, or `NULL`.

  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 method.

`n_fds`

  Type: `int`

  The number of file descriptors in `fds`, or 0 if `fds` is `NULL`.

`map_fds`

  Type: An array of `int`

  An array of integers, or `NULL`.

  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 method.

`n_map_fds`

  Type: `int`

  The number of elements in `map_fds`, or 0 if `map_fds` is `NULL`.

`spawn_flags`

  Type: `GSpawnFlags`

  Flags from `GSpawnFlags`.

`child_setup`

  Type: `GSpawnChildSetupFunc`

  An extra child setup function to run in the child just before exec(), or `NULL`.

  The argument can be `NULL`.

`child_setup_data`

  Type: `gpointer`

  User data for `child_setup`, or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`child_setup_data_destroy`

  Type: `GDestroyNotify`

  A `GDestroyNotify` for `child_setup_data`, or `NULL`.

  The argument can be `NULL`.

`timeout`

  Type: `int`

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

`cancellable`

  Type: `GCancellable`

  A `GCancellable`, or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`callback`

  Type: `VteTerminalSpawnAsyncCallback`

  A `VteTerminalSpawnAsyncCallback`, or `NULL`.

  The argument can be `NULL`.

`user_data`

  Type: `gpointer`

  User data for `callback`, or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.