Function
GLibspawn_sync
Declaration
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
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 |
|
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 |
An array of filename |
|
|
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. | |
envp |
An array of filename |
|
|
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. | |
flags |
GSpawnFlags |
Flags from |
|
child_setup |
GSpawnChildSetupFunc |
Function to run in the child just before |
|
The argument can be NULL . | |
user_data |
gpointer |
User data for |
|
The argument can be NULL . | |
The data is owned by the caller of the function. | |
standard_output |
An array of guint8 |
Return location for child output, or |
|
The argument will be set by the function. | |
The argument can be NULL . | |
The array must be NULL -terminated. | |
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 |
|
The argument will be set by the function. | |
The argument can be NULL . | |
The array must be NULL -terminated. | |
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 |
|
The argument will be set by the function. | |
The argument can be NULL . | |
error |
GError ** |
The return location for a GError* , or NULL . |