[vte] pty: Make vte_pty_child_setup() useful for flatpack



commit 3147319e58f20bee8973088c396acc3cd71034b3
Author: Christian Persch <chpe src gnome org>
Date:   Thu Apr 25 23:53:16 2019 +0200

    pty: Make vte_pty_child_setup() useful for flatpack
    
    Add flags to VtePty to skip starting a new session and setting the PTY
    as controlling TTY for the child process in vte_pty_child_setup(). This
    is used when the process using vte is flatpacked, but wants to run
    the child process in the host.

 src/pty.cc         | 15 +++++++++------
 src/vte/vteenums.h |  6 ++++++
 2 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/pty.cc b/src/pty.cc
index 34660ac5..296df1e3 100644
--- a/src/pty.cc
+++ b/src/pty.cc
@@ -174,16 +174,19 @@ vte_pty_child_setup (VtePty *pty)
                 _exit(127);
         }
 
-       /* Start a new session and become process-group leader. */
 #if defined(HAVE_SETSID) && defined(HAVE_SETPGID)
-       _vte_debug_print (VTE_DEBUG_PTY, "Starting new session\n");
-       setsid();
-       setpgid(0, 0);
+        if (!(priv->flags & VTE_PTY_NO_SESSION)) {
+                /* Start a new session and become process-group leader. */
+                _vte_debug_print (VTE_DEBUG_PTY, "Starting new session\n");
+                setsid();
+                setpgid(0, 0);
+        }
 #endif
 
 #ifdef TIOCSCTTY
-       /* TIOCSCTTY is defined?  Let's try that, too. */
-       ioctl(fd, TIOCSCTTY, fd);
+        if (!(priv->flags & VTE_PTY_NO_CTTY)) {
+                ioctl(fd, TIOCSCTTY, fd);
+        }
 #endif
 
 #if defined(__sun) && defined(HAVE_STROPTS_H)
diff --git a/src/vte/vteenums.h b/src/vte/vteenums.h
index 54c4ee08..84d07a0d 100644
--- a/src/vte/vteenums.h
+++ b/src/vte/vteenums.h
@@ -114,6 +114,10 @@ typedef enum {
  * @VTE_PTY_NO_WTMP: Unused. Deprecated: 0.38
  * @VTE_PTY_NO_HELPER: Unused. Deprecated: 0.38
  * @VTE_PTY_NO_FALLBACK: Unused. Deprecated: 0.38
+ * @VTE_PTY_NO_SESSION: Do not start a new session for the child in
+ *   vte_pty_child_setup(). See man:setsid(2) for more information. Since: 0.58
+ * @VTE_PTY_NO_CTTY: Do not set the PTY as the controlling TTY for the child
+ *   in vte_pty_child_setup(). See man:tty_ioctl(4) for more information. Since: 0.58
  * @VTE_PTY_DEFAULT: the default flags
  */
 typedef enum {
@@ -122,6 +126,8 @@ typedef enum {
   VTE_PTY_NO_WTMP     = 1 << 2,
   VTE_PTY_NO_HELPER   = 1 << 3,
   VTE_PTY_NO_FALLBACK = 1 << 4,
+  VTE_PTY_NO_SESSION  = 1 << 5,
+  VTE_PTY_NO_CTTY     = 1 << 6,
   VTE_PTY_DEFAULT     = 0
 } VtePtyFlags;
 


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