Function

GLibspawn_async_with_fds

since: 2.58

Declaration

gboolean
g_spawn_async_with_fds (
  const gchar* working_directory,
  gchar** argv,
  gchar** envp,
  GSpawnFlags flags,
  GSpawnChildSetupFunc child_setup,
  gpointer user_data,
  GPid* child_pid,
  gint stdin_fd,
  gint stdout_fd,
  gint stderr_fd,
  GError** error
)

Description

Executes a child program asynchronously.

Identical to g_spawn_async_with_pipes_and_fds() but with n_fds set to zero, so no FD assignments are used.

Available since: 2.58

Parameters

working_directory

Type: const gchar*

Child’s current working directory, or NULL to inherit parent’s, in the GLib file name encoding.

The argument can be NULL.
The data is owned by the caller of the function.
The value is a file system path, using the OS encoding.
argv

Type: An array of gchar*

Child’s argument vector, in the GLib file name encoding; it must be non-empty and NULL-terminated.

The array must be NULL-terminated.
The data is owned by the caller of the function.
Each element is a NUL terminated UTF-8 string.
envp

Type: An array of gchar*

Child’s environment, or NULL to inherit parent’s, in the GLib file name encoding.

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 NUL terminated UTF-8 string.
flags

Type: GSpawnFlags

Flags from GSpawnFlags.

child_setup

Type: GSpawnChildSetupFunc

Function to run in the child just before exec()

The argument can be NULL.
user_data

Type: gpointer

User data for child_setup.

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

Type: GPid

Return location for child process ID, or NULL.

The argument will be set by the function.
The argument can be NULL.
The called function takes ownership of the data, and is responsible for freeing it.
stdin_fd

Type: gint

File descriptor to use for child’s stdin, or -1

stdout_fd

Type: gint

File descriptor to use for child’s stdout, or -1

stderr_fd

Type: gint

File descriptor to use for child’s stderr, or -1

error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will left initialized to NULL by the function if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: gboolean

TRUE on success, FALSE if an error was set.