Method

VtePtyspawn_with_fds_async

Declaration [src]

void
vte_pty_spawn_with_fds_async (
  VtePty* pty,
  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,
  GAsyncReadyCallback callback,
  gpointer user_data
)

Description [src]

Starts the specified command under the pseudo-terminal pty. The argv and envv lists should be NULL-terminated. The “TERM” environment variable is automatically set to a default value, but can be overridden from envv. pty_flags controls logging the session to the specified system log files.

Note also 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. Also G_SPAWN_LEAVE_DESCRIPTORS_OPEN is not supported; and G_SPAWN_DO_NOT_REAP_CHILD will always be added to spawn_flags.

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. All file descriptors in fds must have the FD_CLOEXEC flag set on them; it will be unset in the child process before calling man:execve(2). Note also that no file descriptor may be mapped to stdin, stdout, or stderr (file descriptors 0, 1, or 2), since these will be assigned to the PTY. All open file descriptors apart from those mapped as above will be closed when execve() is called.

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.

See vte_pty_new(), and vte_terminal_watch_child() for more information.

Available since:0.62

Parameters

working_directory 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 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 NULL.

 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 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 function.
n_fds int
 

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

map_fds 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 function.
n_map_fds int
 

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

spawn_flags GSpawnFlags
 

Flags from GSpawnFlags.

child_setup GSpawnChildSetupFunc
 

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

 The argument can be NULL.
child_setup_data gpointer
 

User data for child_setup, or NULL.

 The argument can be NULL.
 The data is owned by the caller of the function.
child_setup_data_destroy GDestroyNotify
 

A GDestroyNotify for child_setup_data, or NULL.

 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 GCancellable, or NULL.

 The argument can be NULL.
 The data is owned by the caller of the function.
callback GAsyncReadyCallback
 

A GAsyncReadyCallback, or NULL.

 The argument can be NULL.
user_data gpointer
 

User data for callback.

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