[gnome-builder/wip/gtk4-port] libide/foundry: add ide_run_context_merge_unix_fd_map()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/foundry: add ide_run_context_merge_unix_fd_map()
- Date: Fri, 17 Jun 2022 20:16:36 +0000 (UTC)
commit 1ecf419c85d22f1fdae192b1bfae4c42830ec0ad
Author: Christian Hergert <chergert redhat com>
Date: Fri Jun 17 13:15:38 2022 -0700
libide/foundry: add ide_run_context_merge_unix_fd_map()
This provides external siplified API for handlers to simply merge their
FDs to a lower layer.
src/libide/foundry/ide-run-context.c | 32 ++++++++++++++++++++++++++++++++
src/libide/foundry/ide-run-context.h | 6 +++++-
2 files changed, 37 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/foundry/ide-run-context.c b/src/libide/foundry/ide-run-context.c
index 0bd1599f8..e0a6dac65 100644
--- a/src/libide/foundry/ide-run-context.c
+++ b/src/libide/foundry/ide-run-context.c
@@ -643,3 +643,35 @@ ide_run_context_end (IdeRunContext *self,
return g_steal_pointer (&launcher);
}
+
+/**
+ * ide_run_context_merge_unix_fd_map:
+ * @self: a #IdeRunContext
+ * @unix_fd_map: a #IdeUnixFDMap
+ * @error: a #GError, or %NULL
+ *
+ * Merges the #IdeUnixFDMap into the current layer.
+ *
+ * If there are collisions in destination FDs, then that may cause an
+ * error and %FALSE is returned.
+ *
+ * @unix_fd_map will have the FDs stolen using ide_unix_fd_map_steal_from()
+ * which means that if successful, @unix_fd_map will not have any open
+ * file-descriptors after calling this function.
+ *
+ * Returns: %TRUE if successful; otherwise %FALSE and @error is set.
+ */
+gboolean
+ide_run_context_merge_unix_fd_map (IdeRunContext *self,
+ IdeUnixFDMap *unix_fd_map,
+ GError **error)
+{
+ IdeRunContextLayer *layer;
+
+ g_return_val_if_fail (IDE_IS_RUN_CONTEXT (self), FALSE);
+ g_return_val_if_fail (IDE_IS_UNIX_FD_MAP (unix_fd_map), FALSE);
+
+ layer = ide_run_context_current_layer (self);
+
+ return ide_unix_fd_map_steal_from (layer->unix_fd_map, unix_fd_map, error);
+}
diff --git a/src/libide/foundry/ide-run-context.h b/src/libide/foundry/ide-run-context.h
index dca8bd10e..d7dbe8640 100644
--- a/src/libide/foundry/ide-run-context.h
+++ b/src/libide/foundry/ide-run-context.h
@@ -38,7 +38,7 @@ G_DECLARE_FINAL_TYPE (IdeRunContext, ide_run_context, IDE, RUN_CONTEXT, GObject)
*
* Returns: %TRUE if successful; otherwise %FALSE and @error must be set.
*/
-typedef gboolean (*IdeRunContextHandler) (IdeRunContext *self,
+typedef gboolean (*IdeRunContextHandler) (IdeRunContext *run_context,
const char * const *argv,
const char * const *env,
const char *cwd,
@@ -78,6 +78,10 @@ void ide_run_context_take_fd (IdeRunContext
int source_fd,
int dest_fd);
IDE_AVAILABLE_IN_ALL
+gboolean ide_run_context_merge_unix_fd_map (IdeRunContext *self,
+ IdeUnixFDMap *unix_fd_map,
+ GError **error);
+IDE_AVAILABLE_IN_ALL
void ide_run_context_prepend_argv (IdeRunContext *self,
const char *arg);
IDE_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]