Spawn.asyncWithFds

Identical to Spawn.asyncWithPipes but instead of creating pipes for the stdin/stdout/stderr, you can pass existing file descriptors into this function through the stdin_fd, stdout_fd and stderr_fd parameters. The following flags also have their behaviour slightly tweaked as a result:

G_SPAWN_STDOUT_TO_DEV_NULL means that the child's standard output will be discarded, instead of going to the same location as the parent's standard output. If you use this flag, standard_output must be -1. G_SPAWN_STDERR_TO_DEV_NULL means that the child's standard error will be discarded, instead of going to the same location as the parent's standard error. If you use this flag, standard_error must be -1. G_SPAWN_CHILD_INHERITS_STDIN means that the child will inherit the parent's standard input (by default, the child's standard input is attached to /dev/null). If you use this flag, standard_input must be -1.

It is valid to pass the same fd in multiple parameters (e.g. you can pass a single fd for both stdout and stderr).

class Spawn
static
bool
asyncWithFds

Parameters

workingDirectory string

child's current working directory, or NULL to inherit parent's, in the GLib file name encoding

argv string[]

child's argument vector, in the GLib file name encoding

envp string[]

child's environment, or NULL to inherit parent's, in the GLib file name encoding

flags GSpawnFlags

flags from GSpawnFlags

childSetup GSpawnChildSetupFunc

function to run in the child just before exec()

userData void*

user data for child_setup

childPid GPid

return location for child process ID, or NULL

stdinFd int

file descriptor to use for child's stdin, or -1

stdoutFd int

file descriptor to use for child's stdout, or -1

stderrFd int

file descriptor to use for child's stderr, or -1

Return Value

Type: bool

TRUE on success, FALSE if an error was set

Throws

GException on failure.

Meta

Since

2.58