[gnome-builder/wip/gtk4-port] libide/foundry: add spawn helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/foundry: add spawn helper
- Date: Wed, 22 Jun 2022 19:42:38 +0000 (UTC)
commit 32e382f434f6be76e778e3498e1dd017e2da099f
Author: Christian Hergert <chergert redhat com>
Date: Wed Jun 22 12:41:23 2022 -0700
libide/foundry: add spawn helper
So that we can skip returning the launcher at all and just expose the
spawned subprocess.
src/libide/foundry/ide-run-context.c | 36 ++++++++++++++++++++++++++++++++++++
src/libide/foundry/ide-run-context.h | 3 +++
2 files changed, 39 insertions(+)
---
diff --git a/src/libide/foundry/ide-run-context.c b/src/libide/foundry/ide-run-context.c
index 05527538a..21111224e 100644
--- a/src/libide/foundry/ide-run-context.c
+++ b/src/libide/foundry/ide-run-context.c
@@ -780,6 +780,42 @@ ide_run_context_end (IdeRunContext *self,
return g_steal_pointer (&launcher);
}
+/**
+ * ide_run_context_spawn:
+ * @self: a #IdeRunContext
+ *
+ * Spwans the run command.
+ *
+ * If there is a failure to build the command into a subprocess launcher,
+ * then %NULL is returned and @error is set.
+ *
+ * If the subprocess fails to launch, then %NULL is returned and @error is set.
+ *
+ * Returns: (transfer full): an #IdeSubprocess if successful; otherwise %NULL
+ * and @error is set.
+ */
+IdeSubprocess *
+ide_run_context_spawn (IdeRunContext *self,
+ GError **error)
+{
+ g_autoptr(IdeSubprocessLauncher) launcher = NULL;
+ g_autoptr(IdeSubprocess) ret = NULL;
+
+ IDE_ENTRY;
+
+ g_return_val_if_fail (IDE_IS_RUN_CONTEXT (self), NULL);
+
+ if (!(launcher = ide_run_context_end (self, error)))
+ IDE_RETURN (NULL);
+
+ if (!(ret = ide_subprocess_launcher_spawn (launcher, NULL, error)))
+ IDE_RETURN (NULL);
+
+ g_return_val_if_fail (IDE_IS_SUBPROCESS (ret), NULL);
+
+ IDE_RETURN (g_steal_pointer (&ret));
+}
+
/**
* ide_run_context_merge_unix_fd_map:
* @self: a #IdeRunContext
diff --git a/src/libide/foundry/ide-run-context.h b/src/libide/foundry/ide-run-context.h
index abdc99d10..78435c155 100644
--- a/src/libide/foundry/ide-run-context.h
+++ b/src/libide/foundry/ide-run-context.h
@@ -124,5 +124,8 @@ void ide_run_context_unsetenv (IdeRunContext
IDE_AVAILABLE_IN_ALL
IdeSubprocessLauncher *ide_run_context_end (IdeRunContext *self,
GError **error);
+IDE_AVAILABLE_IN_ALL
+IdeSubprocess *ide_run_context_spawn (IdeRunContext *self,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]