mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 05:56:14 +01:00
Merge branch '3399-glib-gir-platform-differences' into 'main'
gspawn: Move docs/annotations to be platform independent See merge request GNOME/glib!4158
This commit is contained in:
commit
435aeddbc7
1992
glib/gspawn-posix.c
Normal file
1992
glib/gspawn-posix.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,38 @@
|
|||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
#include "gspawn.h"
|
#include "gspawn.h"
|
||||||
|
|
||||||
|
/* Platform-specific implementation functions. */
|
||||||
|
gboolean g_spawn_sync_impl (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);
|
||||||
|
gboolean g_spawn_async_with_pipes_and_fds_impl (const gchar *working_directory,
|
||||||
|
const gchar * const *argv,
|
||||||
|
const gchar * const *envp,
|
||||||
|
GSpawnFlags flags,
|
||||||
|
GSpawnChildSetupFunc child_setup,
|
||||||
|
gpointer user_data,
|
||||||
|
gint stdin_fd,
|
||||||
|
gint stdout_fd,
|
||||||
|
gint stderr_fd,
|
||||||
|
const gint *source_fds,
|
||||||
|
const gint *target_fds,
|
||||||
|
gsize n_fds,
|
||||||
|
GPid *child_pid_out,
|
||||||
|
gint *stdin_pipe_out,
|
||||||
|
gint *stdout_pipe_out,
|
||||||
|
gint *stderr_pipe_out,
|
||||||
|
GError **error);
|
||||||
|
gboolean g_spawn_check_wait_status_impl (gint wait_status,
|
||||||
|
GError **error);
|
||||||
|
void g_spawn_close_pid_impl (GPid pid);
|
||||||
|
|
||||||
static inline gint
|
static inline gint
|
||||||
_g_spawn_exec_err_to_g_error (gint en)
|
_g_spawn_exec_err_to_g_error (gint en)
|
||||||
{
|
{
|
||||||
|
@ -345,28 +345,6 @@ protect_argv (const gchar * const *argv,
|
|||||||
G_DEFINE_QUARK (g-exec-error-quark, g_spawn_error)
|
G_DEFINE_QUARK (g-exec-error-quark, g_spawn_error)
|
||||||
G_DEFINE_QUARK (g-spawn-exit-error-quark, g_spawn_exit_error)
|
G_DEFINE_QUARK (g-spawn-exit-error-quark, g_spawn_exit_error)
|
||||||
|
|
||||||
gboolean
|
|
||||||
g_spawn_async (const gchar *working_directory,
|
|
||||||
gchar **argv,
|
|
||||||
gchar **envp,
|
|
||||||
GSpawnFlags flags,
|
|
||||||
GSpawnChildSetupFunc child_setup,
|
|
||||||
gpointer user_data,
|
|
||||||
GPid *child_pid,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (argv != NULL && argv[0] != NULL, FALSE);
|
|
||||||
|
|
||||||
return g_spawn_async_with_pipes (working_directory,
|
|
||||||
argv, envp,
|
|
||||||
flags,
|
|
||||||
child_setup,
|
|
||||||
user_data,
|
|
||||||
child_pid,
|
|
||||||
NULL, NULL, NULL,
|
|
||||||
error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Avoids a danger in threaded situations (calling close()
|
/* Avoids a danger in threaded situations (calling close()
|
||||||
* on a file descriptor twice, and another thread has
|
* on a file descriptor twice, and another thread has
|
||||||
* re-opened it since the first close)
|
* re-opened it since the first close)
|
||||||
@ -1106,16 +1084,16 @@ fork_exec (gint *exit_status,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
g_spawn_sync (const gchar *working_directory,
|
g_spawn_sync_impl (const gchar *working_directory,
|
||||||
gchar **argv,
|
gchar **argv,
|
||||||
gchar **envp,
|
gchar **envp,
|
||||||
GSpawnFlags flags,
|
GSpawnFlags flags,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gchar **standard_output,
|
gchar **standard_output,
|
||||||
gchar **standard_error,
|
gchar **standard_error,
|
||||||
gint *wait_status,
|
gint *wait_status,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint outpipe = -1;
|
gint outpipe = -1;
|
||||||
gint errpipe = -1;
|
gint errpipe = -1;
|
||||||
@ -1353,108 +1331,23 @@ g_spawn_sync (const gchar *working_directory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
g_spawn_async_with_pipes (const gchar *working_directory,
|
g_spawn_async_with_pipes_and_fds_impl (const gchar *working_directory,
|
||||||
gchar **argv,
|
const gchar * const *argv,
|
||||||
gchar **envp,
|
const gchar * const *envp,
|
||||||
GSpawnFlags flags,
|
GSpawnFlags flags,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
GPid *child_pid,
|
gint stdin_fd,
|
||||||
gint *standard_input,
|
gint stdout_fd,
|
||||||
gint *standard_output,
|
gint stderr_fd,
|
||||||
gint *standard_error,
|
const gint *source_fds,
|
||||||
GError **error)
|
const gint *target_fds,
|
||||||
{
|
gsize n_fds,
|
||||||
g_return_val_if_fail (argv != NULL && argv[0] != NULL, FALSE);
|
GPid *child_pid_out,
|
||||||
g_return_val_if_fail (standard_output == NULL ||
|
gint *stdin_pipe_out,
|
||||||
!(flags & G_SPAWN_STDOUT_TO_DEV_NULL), FALSE);
|
gint *stdout_pipe_out,
|
||||||
g_return_val_if_fail (standard_error == NULL ||
|
gint *stderr_pipe_out,
|
||||||
!(flags & G_SPAWN_STDERR_TO_DEV_NULL), FALSE);
|
GError **error)
|
||||||
/* can't inherit stdin if we have an input pipe. */
|
|
||||||
g_return_val_if_fail (standard_input == NULL ||
|
|
||||||
!(flags & G_SPAWN_CHILD_INHERITS_STDIN), FALSE);
|
|
||||||
|
|
||||||
return fork_exec (NULL,
|
|
||||||
(flags & G_SPAWN_DO_NOT_REAP_CHILD),
|
|
||||||
working_directory,
|
|
||||||
(const gchar * const *) argv,
|
|
||||||
(const gchar * const *) envp,
|
|
||||||
flags,
|
|
||||||
child_setup,
|
|
||||||
user_data,
|
|
||||||
child_pid,
|
|
||||||
standard_input,
|
|
||||||
standard_output,
|
|
||||||
standard_error,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
-1,
|
|
||||||
NULL, NULL, 0,
|
|
||||||
NULL,
|
|
||||||
error);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
g_spawn_async_with_fds (const gchar *working_directory,
|
|
||||||
gchar **argv,
|
|
||||||
gchar **envp,
|
|
||||||
GSpawnFlags flags,
|
|
||||||
GSpawnChildSetupFunc child_setup,
|
|
||||||
gpointer user_data,
|
|
||||||
GPid *child_pid,
|
|
||||||
gint stdin_fd,
|
|
||||||
gint stdout_fd,
|
|
||||||
gint stderr_fd,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (argv != NULL && argv[0] != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (stdin_fd == -1 ||
|
|
||||||
!(flags & G_SPAWN_STDOUT_TO_DEV_NULL), FALSE);
|
|
||||||
g_return_val_if_fail (stderr_fd == -1 ||
|
|
||||||
!(flags & G_SPAWN_STDERR_TO_DEV_NULL), FALSE);
|
|
||||||
/* can't inherit stdin if we have an input pipe. */
|
|
||||||
g_return_val_if_fail (stdin_fd == -1 ||
|
|
||||||
!(flags & G_SPAWN_CHILD_INHERITS_STDIN), FALSE);
|
|
||||||
|
|
||||||
return fork_exec (NULL,
|
|
||||||
(flags & G_SPAWN_DO_NOT_REAP_CHILD),
|
|
||||||
working_directory,
|
|
||||||
(const gchar * const *) argv,
|
|
||||||
(const gchar * const *) envp,
|
|
||||||
flags,
|
|
||||||
child_setup,
|
|
||||||
user_data,
|
|
||||||
child_pid,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
stdin_fd,
|
|
||||||
stdout_fd,
|
|
||||||
stderr_fd,
|
|
||||||
NULL, NULL, 0,
|
|
||||||
NULL,
|
|
||||||
error);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
g_spawn_async_with_pipes_and_fds (const gchar *working_directory,
|
|
||||||
const gchar * const *argv,
|
|
||||||
const gchar * const *envp,
|
|
||||||
GSpawnFlags flags,
|
|
||||||
GSpawnChildSetupFunc child_setup,
|
|
||||||
gpointer user_data,
|
|
||||||
gint stdin_fd,
|
|
||||||
gint stdout_fd,
|
|
||||||
gint stderr_fd,
|
|
||||||
const gint *source_fds,
|
|
||||||
const gint *target_fds,
|
|
||||||
gsize n_fds,
|
|
||||||
GPid *child_pid_out,
|
|
||||||
gint *stdin_pipe_out,
|
|
||||||
gint *stdout_pipe_out,
|
|
||||||
gint *stderr_pipe_out,
|
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (argv != NULL && argv[0] != NULL, FALSE);
|
g_return_val_if_fail (argv != NULL && argv[0] != NULL, FALSE);
|
||||||
g_return_val_if_fail (stdout_pipe_out == NULL ||
|
g_return_val_if_fail (stdout_pipe_out == NULL ||
|
||||||
@ -1491,69 +1384,8 @@ g_spawn_async_with_pipes_and_fds (const gchar *working_directory,
|
|||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
g_spawn_command_line_sync (const gchar *command_line,
|
|
||||||
gchar **standard_output,
|
|
||||||
gchar **standard_error,
|
|
||||||
gint *wait_status,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
gboolean retval;
|
|
||||||
gchar **argv = 0;
|
|
||||||
|
|
||||||
g_return_val_if_fail (command_line != NULL, FALSE);
|
|
||||||
|
|
||||||
/* This will return a runtime error if @command_line is the empty string. */
|
|
||||||
if (!g_shell_parse_argv (command_line,
|
|
||||||
NULL, &argv,
|
|
||||||
error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
retval = g_spawn_sync (NULL,
|
|
||||||
argv,
|
|
||||||
NULL,
|
|
||||||
G_SPAWN_SEARCH_PATH,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
standard_output,
|
|
||||||
standard_error,
|
|
||||||
wait_status,
|
|
||||||
error);
|
|
||||||
g_strfreev (argv);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
g_spawn_command_line_async (const gchar *command_line,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
gboolean retval;
|
|
||||||
gchar **argv = 0;
|
|
||||||
|
|
||||||
g_return_val_if_fail (command_line != NULL, FALSE);
|
|
||||||
|
|
||||||
/* This will return a runtime error if @command_line is the empty string. */
|
|
||||||
if (!g_shell_parse_argv (command_line,
|
|
||||||
NULL, &argv,
|
|
||||||
error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
retval = g_spawn_async (NULL,
|
|
||||||
argv,
|
|
||||||
NULL,
|
|
||||||
G_SPAWN_SEARCH_PATH,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
error);
|
|
||||||
g_strfreev (argv);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
g_spawn_close_pid (GPid pid)
|
g_spawn_close_pid_impl (GPid pid)
|
||||||
{
|
{
|
||||||
/* CRT functions such as _wspawn* return (HANDLE)-1
|
/* CRT functions such as _wspawn* return (HANDLE)-1
|
||||||
* on failure, so check also for that value. */
|
* on failure, so check also for that value. */
|
||||||
@ -1562,8 +1394,8 @@ g_spawn_close_pid (GPid pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
g_spawn_check_wait_status (gint wait_status,
|
g_spawn_check_wait_status_impl (gint wait_status,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
@ -1582,13 +1414,6 @@ g_spawn_check_wait_status (gint wait_status,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
g_spawn_check_exit_status (gint wait_status,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
return g_spawn_check_wait_status (wait_status, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
|
||||||
/* Binary compatibility versions. Not for newly compiled code. */
|
/* Binary compatibility versions. Not for newly compiled code. */
|
||||||
|
1960
glib/gspawn.c
1960
glib/gspawn.c
File diff suppressed because it is too large
Load Diff
@ -320,6 +320,7 @@ glib_sources += files(
|
|||||||
'gshell.c',
|
'gshell.c',
|
||||||
'gslice.c',
|
'gslice.c',
|
||||||
'gslist.c',
|
'gslist.c',
|
||||||
|
'gspawn.c',
|
||||||
'gstdio.c',
|
'gstdio.c',
|
||||||
'gstrfuncs.c',
|
'gstrfuncs.c',
|
||||||
'gstring.c',
|
'gstring.c',
|
||||||
@ -371,7 +372,7 @@ if host_system == 'windows'
|
|||||||
glib_sources += files('dirent/wdirent.c')
|
glib_sources += files('dirent/wdirent.c')
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
|
glib_sources += files('glib-unix.c', 'gspawn-posix.c', 'giounix.c')
|
||||||
platform_deps = []
|
platform_deps = []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ glib/gmarkup.c
|
|||||||
glib/goption.c
|
glib/goption.c
|
||||||
glib/gregex.c
|
glib/gregex.c
|
||||||
glib/gshell.c
|
glib/gshell.c
|
||||||
glib/gspawn.c
|
glib/gspawn-posix.c
|
||||||
glib/gspawn-private.h
|
glib/gspawn-private.h
|
||||||
glib/gspawn-win32.c
|
glib/gspawn-win32.c
|
||||||
glib/gstrfuncs.c
|
glib/gstrfuncs.c
|
||||||
|
Loading…
Reference in New Issue
Block a user