[vte] pty: Start new session before opening the PTY peer



commit 171fd49e24111749c415ec1e92efcd65f08fdcf6
Author: Christian Persch <chpe src gnome org>
Date:   Sat Oct 12 20:10:55 2019 +0200

    pty: Start new session before opening the PTY peer

 src/pty.cc | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/src/pty.cc b/src/pty.cc
index df60c9f5..637acae1 100644
--- a/src/pty.cc
+++ b/src/pty.cc
@@ -131,6 +131,17 @@ Pty::child_setup() const noexcept
                 _exit(127);
         }
 
+#if defined(HAVE_SETSID) && defined(HAVE_SETPGID)
+        if (!(m_flags & VTE_PTY_NO_SESSION)) {
+                /* Start a new session and become process-group leader.
+                 * This also loses the controlling TTY.
+                 */
+                _vte_debug_print (VTE_DEBUG_PTY, "Starting new session\n");
+                setsid();
+                setpgid(0, 0);
+        }
+#endif
+
         /* Note: *not* O_CLOEXEC! */
         auto const fd_flags = int{O_RDWR | ((m_flags & VTE_PTY_NO_CTTY) ? O_NOCTTY : 0)};
         auto fd = int{-1};
@@ -172,15 +183,6 @@ Pty::child_setup() const noexcept
 
         assert(fd != -1);
 
-#if defined(HAVE_SETSID) && defined(HAVE_SETPGID)
-        if (!(m_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
         if (!(m_flags & VTE_PTY_NO_CTTY)) {
                 ioctl(fd, TIOCSCTTY, fd);


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