spawnSync

fnbool spawnSync(string workingDirectory, string[] argv, string[] envp, glib.types.SpawnFlags flags, glib.types.SpawnChildSetupFunc childSetup, out string standardOutput, out string standardError, out int waitStatus)

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 [glib.global.spawnCheckWaitStatus] 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 [glib.global.childWatchSourceNew] apply.

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

This function calls [glib.global.spawnAsyncWithPipes] internally; see that function for full details on the other parameters and details on how these functions work on Windows.

Parameters

workingDirectorychild's current working directory, or null to inherit parent's
argvchild's argument vector, which must be non-empty and null-terminated
envpchild's environment, or null to inherit parent's
flagsflags from #GSpawnFlags
childSetupfunction to run in the child just before exec()
standardOutputreturn location for child output, or null
standardErrorreturn location for child error messages, or null
waitStatusreturn location for child wait status, as returned by waitpid(), or null

Returns

true on success, false if an error was set

Throws

[ErrorWrap]