[gnome-builder/gnome-builder-3-32] podman: notify podman-exec of number of FDs to inherit



commit 3c1876bbaf511ed10510ce61cb22474b1cba6e82
Author: Christian Hergert <chergert redhat com>
Date:   Wed Apr 3 13:47:18 2019 -0700

    podman: notify podman-exec of number of FDs to inherit
    
    This uses the new --preserve-fds parameter to podman if/when we need to
    pass FDs across to the new process.

 src/plugins/podman/gbp-podman-subprocess-launcher.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/src/plugins/podman/gbp-podman-subprocess-launcher.c 
b/src/plugins/podman/gbp-podman-subprocess-launcher.c
index 4e2201501..118b944cb 100644
--- a/src/plugins/podman/gbp-podman-subprocess-launcher.c
+++ b/src/plugins/podman/gbp-podman-subprocess-launcher.c
@@ -73,6 +73,7 @@ gbp_podman_subprocess_launcher_spawn (IdeSubprocessLauncher  *launcher,
       const gchar * const *environ;
       const gchar *cwd;
       guint i = 0;
+      gint max_fd;
 
       ide_subprocess_launcher_insert_argv (launcher, i++, "podman");
       ide_subprocess_launcher_insert_argv (launcher, i++, "exec");
@@ -87,6 +88,21 @@ gbp_podman_subprocess_launcher_spawn (IdeSubprocessLauncher  *launcher,
           ide_subprocess_launcher_insert_argv (launcher, i++, cwd);
         }
 
+      /* Determine how many FDs we need to preserve.
+       *
+       * From man podman-exec:
+       *
+       * Pass down to the process N additional file descriptors (in addition to
+       * 0, 1, 2).  The total FDs will be 3+N.
+       */
+      if ((max_fd = _ide_subprocess_launcher_get_max_fd (launcher)) > 2)
+        {
+          g_autofree gchar *max_fd_param = NULL;
+
+          max_fd_param = g_strdup_printf ("--preserve-fds=%d", max_fd - 2);
+          ide_subprocess_launcher_insert_argv (launcher, i++, max_fd_param);
+        }
+
       if (!ide_subprocess_launcher_get_clear_env (launcher))
         {
           copy_envvar (launcher, i++, "COLORTERM");


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