Function
Shellutil_spawn_async_with_pipes_and_fds
Declaration [src]
GPid
shell_util_spawn_async_with_pipes_and_fds (
const char* working_directory,
const char* const* argv,
const char* const* envp,
GSpawnFlags flags,
int stdin_fd,
int stdout_fd,
int stderr_fd,
const int* source_fds,
const int* target_fds,
size_t n_fds,
int* stdin_pipe_out,
int* stdout_pipe_out,
int* stderr_pipe_out,
GError** error
)
Description [src]
A wrapper around g_spawn_async_with_pipes_and_fds()
with async-signal-safe
implementation of GSpawnChildSetupFunc
to launch a child program
asynchronously resetting the rlimit nofile on child setup.
Parameters
working_directory
-
Type:
const char*
Child’s current working directory, or
NULL
to inherit parent’s, in the GLib file name encoding.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
char*
Child’s argument vector, in the GLib file name encoding; it 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 NUL terminated UTF-8 string. envp
-
Type: An array of
char*
child's environment, or `NULL` to inherit parent's, in the GLib file name encoding.
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 NUL terminated UTF-8 string. flags
-
Type:
GSpawnFlags
Flags from
GSpawnFlags
. stdin_fd
-
Type:
int
File descriptor to use for child’s stdin, or
-1
. stdout_fd
-
Type:
int
File descriptor to use for child’s stdout, or
-1
. stderr_fd
-
Type:
int
File descriptor to use for child’s stderr, or
-1
. source_fds
-
Type: An array of
int
Array of FDs from the parent process to make available in the child process.
The argument can be NULL
.The length of the array is specified in the n_fds
argument.The data is owned by the caller of the function. target_fds
-
Type: An array of
int
Array of FDs to remap
source_fds
to in the child process.The argument can be NULL
.The length of the array is specified in the n_fds
argument.The data is owned by the caller of the function. n_fds
-
Type:
size_t
Number of FDs in
source_fds
andtarget_fds
. stdin_pipe_out
-
Type:
int*
Return location for file descriptor to write to child’s stdin, or
NULL
.The argument will be set by the function. The argument can be NULL
. stdout_pipe_out
-
Type:
int*
Return location for file descriptor to read child’s stdout, or
NULL
.The argument will be set by the function. The argument can be NULL
. stderr_pipe_out
-
Type:
int*
Return location for file descriptor to read child’s stderr, 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.
Return value
Type: GPid
The PID of the child on success, 0 if error is set.