Function

GLibspawn_sync

Declaration [src]

gboolean
g_spawn_sync (
  const gchar* working_directory,
  gchar** argv,
  gchar** envp,
  GSpawnFlags flags,
  GSpawnChildSetupFunc child_setup,
  gpointer user_data,
  gchar** standard_output,
  gchar** standard_error,
  gint* wait_status,
  GError** error
)

Description [src]

Executes a child synchronously (waits for the child to exit before returning).

All output from the child is stored in standard_output and standard_error, if those parameters are non-NULL. Note that you must set the G_SPAWN_STDOUT_TO_DEV_NULL and G_SPAWN_STDERR_TO_DEV_NULL flags when passing NULL for standard_output and standard_error.

If wait_status is non-NULL, the platform-specific status of the child is stored there; see the documentation of g_spawn_check_wait_status() for how to use and interpret this. On Unix platforms, note that it is usually not equal to the integer passed to exit() or returned from main().

Note that it is invalid to pass G_SPAWN_DO_NOT_REAP_CHILD in flags, and on POSIX platforms, the same restrictions as for g_child_watch_source_new() apply.

If an error occurs, no data is returned in standard_output, standard_error, or wait_status.

This function calls g_spawn_async_with_pipes() internally; see that function for full details on the other parameters and details on how these functions work on Windows.

Parameters

working_directory const gchar*
 

Child’s current working directory, or NULL to inherit parent’s.

 The argument can be NULL.
 The data is owned by the caller of the function.
 The string is a file system path, using the OS encoding.
argv An array of filename
 
child's argument vector.
 The data is owned by the caller of the function.
envp An array of filename
 
child's environment, or `NULL` to inherit parent's.
 The argument can be NULL.
 The data is owned by the caller of the function.
flags GSpawnFlags
 

Flags from GSpawnFlags.

child_setup GSpawnChildSetupFunc
 

Function to run in the child just before exec()

user_data gpointer
 

User data for child_setup.

standard_output An array of guint8
 

Return location for child output, 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.
standard_error An array of guint8
 

Return location for child error messages, 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.
wait_status gint*
 

Return location for child wait status, as returned by waitpid(), 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.
error GError **
  The return location for a GError*, or NULL.

Return value

Returns: gboolean
 

TRUE on success, FALSE if an error was set.