[sysprof] libsysprof: add accessors for setting spawnable flags



commit 1587bc13b6e84b80b34f745ff4934757ac4f7b36
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 1 12:40:20 2022 -0700

    libsysprof: add accessors for setting spawnable flags
    
    We need this to be able to allow inheriting stdin from sysprof-cli.

 src/libsysprof/sysprof-spawnable.c | 50 ++++++++++++++++++++++++++++++++------
 src/libsysprof/sysprof-spawnable.h |  5 ++++
 2 files changed, 48 insertions(+), 7 deletions(-)
---
diff --git a/src/libsysprof/sysprof-spawnable.c b/src/libsysprof/sysprof-spawnable.c
index 182ccb95..b152c1b2 100644
--- a/src/libsysprof/sysprof-spawnable.c
+++ b/src/libsysprof/sysprof-spawnable.c
@@ -34,12 +34,13 @@ typedef struct
 
 struct _SysprofSpawnable
 {
-  GObject     parent_instance;
-  GArray     *fds;
-  GPtrArray  *argv;
-  gchar     **environ;
-  gchar      *cwd;
-  gint        next_fd;
+  GObject           parent_instance;
+  GArray           *fds;
+  GPtrArray        *argv;
+  char            **environ;
+  char             *cwd;
+  gint              next_fd;
+  GSubprocessFlags  flags;
 };
 
 G_DEFINE_TYPE (SysprofSpawnable, sysprof_spawnable, G_TYPE_OBJECT)
@@ -57,6 +58,41 @@ sysprof_spawnable_new (void)
   return g_object_new (SYSPROF_TYPE_SPAWNABLE, NULL);
 }
 
+/**
+ * sysprof_spawnable_get_flags:
+ * @self: a #SysprofSpawnable
+ *
+ * Gets the subprocess flags for spawning.
+ *
+ * Returns: the #GSubprocessFlags bitwise-or'd
+ *
+ * Since: 3.46
+ */
+GSubprocessFlags
+sysprof_spawnable_get_flags (SysprofSpawnable *self)
+{
+  g_return_val_if_fail (SYSPROF_IS_SPAWNABLE (self), 0);
+
+  return self->flags;
+}
+
+/**
+ * sysprof_spawnable_set_flags:
+ * @self: a #SysprofSpawnable
+ *
+ * Set the flags to use when spawning the process.
+ *
+ * Since: 3.46
+ */
+void
+sysprof_spawnable_set_flags (SysprofSpawnable *self,
+                             GSubprocessFlags  flags)
+{
+  g_return_if_fail (SYSPROF_IS_SPAWNABLE (self));
+
+  self->flags = flags;
+}
+
 static void
 fd_mapping_clear (gpointer data)
 {
@@ -268,7 +304,7 @@ sysprof_spawnable_spawn (SysprofSpawnable  *self,
 
   g_return_val_if_fail (SYSPROF_IS_SPAWNABLE (self), NULL);
 
-  launcher = g_subprocess_launcher_new (0);
+  launcher = g_subprocess_launcher_new (self->flags);
 
   g_subprocess_launcher_set_environ (launcher, self->environ);
 
diff --git a/src/libsysprof/sysprof-spawnable.h b/src/libsysprof/sysprof-spawnable.h
index 56be5141..e6d835bf 100644
--- a/src/libsysprof/sysprof-spawnable.h
+++ b/src/libsysprof/sysprof-spawnable.h
@@ -77,5 +77,10 @@ void                 sysprof_spawnable_set_starting_fd (SysprofSpawnable
 SYSPROF_AVAILABLE_IN_ALL
 GSubprocess         *sysprof_spawnable_spawn           (SysprofSpawnable          *self,
                                                         GError                   **error);
+SYSPROF_AVAILABLE_IN_3_46
+GSubprocessFlags     sysprof_spawnable_get_flags       (SysprofSpawnable          *self);
+SYSPROF_AVAILABLE_IN_3_46
+void                 sysprof_spawnable_set_flags       (SysprofSpawnable          *self,
+                                                        GSubprocessFlags           flags);
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]