[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 43/65] glib-compat: add g_spawn_async_with_fds() fall
From: |
Samuel Thibault |
Subject: |
[Qemu-devel] [PULL 43/65] glib-compat: add g_spawn_async_with_fds() fallback |
Date: |
Mon, 14 Jan 2019 01:03:04 +0100 |
From: Marc-André Lureau <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>
---
include/glib-compat.h | 56 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/include/glib-compat.h b/include/glib-compat.h
index fdf95a255d..8a078c5288 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -83,6 +83,62 @@ static inline gboolean g_strv_contains_qemu(const gchar
*const *strv,
}
#define g_strv_contains(a, b) g_strv_contains_qemu(a, b)
+#if !GLIB_CHECK_VERSION(2, 58, 0)
+typedef struct QemuGSpawnFds {
+ GSpawnChildSetupFunc child_setup;
+ gpointer user_data;
+ gint stdin_fd;
+ gint stdout_fd;
+ gint stderr_fd;
+} QemuGSpawnFds;
+
+static inline void
+qemu_gspawn_fds_setup(gpointer user_data)
+{
+ QemuGSpawnFds *q = (QemuGSpawnFds *)user_data;
+
+ dup2(q->stdin_fd, 0);
+ dup2(q->stdout_fd, 1);
+ dup2(q->stderr_fd, 2);
+ q->child_setup(q->user_data);
+}
+#endif
+
+static inline gboolean
+g_spawn_async_with_fds_qemu(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)
+{
+#if GLIB_CHECK_VERSION(2, 58, 0)
+ return g_spawn_async_with_fds(working_directory, argv, envp, flags,
+ child_setup, user_data,
+ child_pid, stdin_fd, stdout_fd, stderr_fd,
+ error);
+#else
+ QemuGSpawnFds setup = {
+ .child_setup = child_setup,
+ .user_data = user_data,
+ .stdin_fd = stdin_fd,
+ .stdout_fd = stdout_fd,
+ .stderr_fd = stderr_fd,
+ };
+
+ return g_spawn_async(working_directory, argv, envp, flags,
+ qemu_gspawn_fds_setup, &setup,
+ child_pid, error);
+#endif
+}
+
+#define g_spawn_async_with_fds(wd, argv, env, f, c, d, p, ifd, ofd, efd, err) \
+ g_spawn_async_with_fds_qemu(wd, argv, env, f, c, d, p, ifd, ofd, efd, err)
#if defined(_WIN32) && !GLIB_CHECK_VERSION(2, 50, 0)
/*
--
2.20.1
- [Qemu-devel] [PULL 28/65] slirp: remove unused DECLARE_IOVEC, (continued)
- [Qemu-devel] [PULL 28/65] slirp: remove unused DECLARE_IOVEC, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 30/65] slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 41/65] slirp: replace ARRAY_SIZE with G_N_ELEMENTS, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 39/65] slirp: NULL is defined by stddef.h, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 20/65] slirp: remove unused HAVE_SYS_BITYPES_H, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 33/65] slirp: remove unused global slirp_instance, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 31/65] slirp: replace SIZEOF_CHAR_P with glib equivalent, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 45/65] slirp: replace error_report() with g_critical(), Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 42/65] net: do not depend on slirp internals, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 19/65] slirp: remove HAVE_SYS_SIGNAL_H, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 43/65] glib-compat: add g_spawn_async_with_fds() fallback,
Samuel Thibault <=
- [Qemu-devel] [PULL 34/65] slirp: replace error_report() with g_critical(), Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 36/65] slirp: add a callback to log guest errors, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 35/65] slirp: improve a bit the debug macros, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 46/65] slirp: Enable fork_exec support on Windows, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 40/65] slirp: remove dead TCP_ACK_HACK code, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 26/65] slirp: remove HAVE_SYS_IOCTL_H, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 23/65] slirp: remove unused HAVE_ARPA_INET_H, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 25/65] slirp: remove unused HAVE_SYS_SELECT_H, Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 38/65] slirp: remove unused sbflush(), Samuel Thibault, 2019/01/13
- [Qemu-devel] [PULL 16/65] slirp: remove PROBE_CONN dead-code, Samuel Thibault, 2019/01/13