mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
GSubprocess: New class for spawning child processes
There are a number of nice things this class brings: 0) Has a race-free termination API on all platforms (on UNIX, calls to kill() and waitpid() are coordinated as not to cause problems). 1) Operates in terms of G{Input,Output}Stream, not file descriptors 2) Standard GIO-style async API for wait() with cancellation 3) Makes some simple cases easy, like synchronously spawning a process with an argument list 4) Makes hard cases possible, like asynchronously running a process with stdout/stderr merged, output directly to a file path Much rewriting and code review from Ryan Lortie <desrt@desrt.ca> https://bugzilla.gnome.org/show_bug.cgi?id=672102
This commit is contained in:
committed by
Ryan Lortie
parent
e30bbca667
commit
5b48dc40cc
@@ -1696,6 +1696,56 @@ typedef enum /*< flags >*/ {
|
||||
G_TEST_DBUS_NONE = 0
|
||||
} GTestDBusFlags;
|
||||
|
||||
/**
|
||||
* GSubprocessFlags:
|
||||
* @G_SUBPROCESS_FLAGS_NONE: No flags.
|
||||
* @G_SUBPROCESS_FLAGS_STDIN_PIPE: create a pipe for the stdin of the
|
||||
* spawned process that can be accessed with
|
||||
* g_subprocess_get_stdin_pipe().
|
||||
* @G_SUBPROCESS_FLAGS_STDIN_INHERIT: stdin is inherited from the
|
||||
* calling process.
|
||||
* @G_SUBPROCESS_FLAGS_STDOUT_PIPE: create a pipe for the stdout of the
|
||||
* spawned process that can be accessed with
|
||||
* g_subprocess_get_stdout_pipe().
|
||||
* @G_SUBPROCESS_FLAGS_STDOUT_SILENCE: silence the stdout of the spawned
|
||||
* process (ie: redirect to /dev/null).
|
||||
* @G_SUBPROCESS_FLAGS_STDERR_PIPE: create a pipe for the stderr of the
|
||||
* spawned process that can be accessed with
|
||||
* g_subprocess_get_stderr_pipe().
|
||||
* @G_SUBPROCESS_FLAGS_STDERR_SILENCE: silence the stderr of the spawned
|
||||
* process (ie: redirect to /dev/null).
|
||||
* @G_SUBPROCESS_FLAGS_STDERR_MERGE: merge the stderr of the spawned
|
||||
* process with whatever the stdout happens to be. This is a good way
|
||||
* of directing both streams to a common log file, for example.
|
||||
* @G_SUBPROCESS_FLAGS_INHERIT_FDS: spawned processes will inherit the
|
||||
* file descriptors of their parent, unless those descriptors have
|
||||
* been explicitly marked as close-on-exec. This flag has no effect
|
||||
* over the "standard" file descriptors (stdin, stdout, stderr).
|
||||
*
|
||||
* Flags to define the behaviour of a #GSubprocess.
|
||||
*
|
||||
* Note that the default for stdin is to redirect from /dev/null. For
|
||||
* stdout and stderr the default are for them to inherit the
|
||||
* corresponding descriptor from the calling process.
|
||||
*
|
||||
* Note that it is a programmer error to mix 'incompatible' flags. For
|
||||
* example, you may not request both %G_SUBPROCESS_FLAGS_STDOUT_PIPE and
|
||||
* %G_SUBPROCESS_FLAGS_STDOUT_SILENCE.
|
||||
*
|
||||
* Since: 2.36
|
||||
**/
|
||||
typedef enum {
|
||||
G_SUBPROCESS_FLAGS_NONE = 0,
|
||||
G_SUBPROCESS_FLAGS_STDIN_PIPE = (1u << 0),
|
||||
G_SUBPROCESS_FLAGS_STDIN_INHERIT = (1u << 1),
|
||||
G_SUBPROCESS_FLAGS_STDOUT_PIPE = (1u << 2),
|
||||
G_SUBPROCESS_FLAGS_STDOUT_SILENCE = (1u << 3),
|
||||
G_SUBPROCESS_FLAGS_STDERR_PIPE = (1u << 4),
|
||||
G_SUBPROCESS_FLAGS_STDERR_SILENCE = (1u << 5),
|
||||
G_SUBPROCESS_FLAGS_STDERR_MERGE = (1u << 6),
|
||||
G_SUBPROCESS_FLAGS_INHERIT_FDS = (1u << 7)
|
||||
} GSubprocessFlags;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIO_ENUMS_H__ */
|
||||
|
Reference in New Issue
Block a user