gspawn: Simplify async_with_pipes code

Be consistent with its docblock and directly call
`g_spawn_async_with_pipes_and_fds()` with the appropriate arguments.
This commit is contained in:
Nicola Fontana 2022-05-02 10:47:55 +02:00
parent 0c6a1af9d6
commit ac2ab3d3c6

View File

@ -239,8 +239,6 @@ g_spawn_async (const gchar *working_directory,
GPid *child_pid, GPid *child_pid,
GError **error) GError **error)
{ {
g_return_val_if_fail (argv != NULL, FALSE);
return g_spawn_async_with_pipes (working_directory, return g_spawn_async_with_pipes (working_directory,
argv, envp, argv, envp,
flags, flags,
@ -610,37 +608,18 @@ g_spawn_async_with_pipes (const gchar *working_directory,
gint *standard_error, gint *standard_error,
GError **error) GError **error)
{ {
g_return_val_if_fail (argv != NULL, FALSE); return g_spawn_async_with_pipes_and_fds (working_directory,
g_return_val_if_fail (argv[0] != NULL, FALSE); (const gchar * const *) argv,
g_return_val_if_fail (standard_output == NULL || (const gchar * const *) envp,
!(flags & G_SPAWN_STDOUT_TO_DEV_NULL), FALSE); flags,
g_return_val_if_fail (standard_error == NULL || child_setup, user_data,
!(flags & G_SPAWN_STDERR_TO_DEV_NULL), FALSE); -1, -1, -1,
/* can't inherit stdin if we have an input pipe. */ NULL, NULL, 0,
g_return_val_if_fail (standard_input == NULL || child_pid,
!(flags & G_SPAWN_CHILD_INHERITS_STDIN), FALSE); standard_input,
standard_output,
return fork_exec (!(flags & G_SPAWN_DO_NOT_REAP_CHILD), standard_error,
working_directory, error);
(const gchar * const *) argv,
(const gchar * const *) envp,
!(flags & G_SPAWN_LEAVE_DESCRIPTORS_OPEN),
(flags & G_SPAWN_SEARCH_PATH) != 0,
(flags & G_SPAWN_SEARCH_PATH_FROM_ENVP) != 0,
(flags & G_SPAWN_STDOUT_TO_DEV_NULL) != 0,
(flags & G_SPAWN_STDERR_TO_DEV_NULL) != 0,
(flags & G_SPAWN_CHILD_INHERITS_STDIN) != 0,
(flags & G_SPAWN_FILE_AND_ARGV_ZERO) != 0,
(flags & G_SPAWN_CLOEXEC_PIPES) != 0,
child_setup,
user_data,
child_pid,
standard_input,
standard_output,
standard_error,
-1, -1, -1,
NULL, NULL, 0,
error);
} }
/** /**