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
-
Type:
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 value is a platform-native string, using the preferred OS encoding on Unix and UTF-8 on Windows. argv
-
Type: An array of
filename
child's argument vector, which 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 platform-native string, using the preferred OS encoding on Unix and UTF-8 on Windows.. envp
-
Type: An array of
filename
child's environment, or `NULL` to inherit parent's.
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 platform-native string, using the preferred OS encoding on Unix and UTF-8 on Windows.. 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. standard_output
-
Type: 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 array must be NULL
-terminated.The caller of the function takes ownership of the returned data, and is responsible for freeing it. standard_error
-
Type: 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 array must be NULL
-terminated.The caller of the function takes ownership of the returned data, and is responsible for freeing it. wait_status
-
Type:
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
. 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 aNULL
GError*
.The argument will be 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.