[vte] pty: Defer grantpt/unlockpt to the child setup



commit 4ed174cefead28e21a5ce52935023d88cfbf4fff
Author: Christian Persch <chpe gnome org>
Date:   Mon Dec 7 22:51:08 2015 +0100

    pty: Defer grantpt/unlockpt to the child setup

 src/pty.cc |   28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/pty.cc b/src/pty.cc
index 7892942..f93739a 100644
--- a/src/pty.cc
+++ b/src/pty.cc
@@ -228,6 +228,19 @@ vte_pty_child_setup (VtePty *pty)
         if (masterfd == -1)
                 _exit(127);
 
+#ifdef HAVE_UNIX98_PTY
+        /* Read the slave number and unlock it. */
+        if (grantpt(masterfd) != 0) {
+                _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m", "grantpt");
+                _exit(127);
+        }
+
+       if (unlockpt(masterfd) != 0) {
+                _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m", "unlockpt");
+                _exit(127);
+        }
+#endif
+
        char *name = ptsname(masterfd);
         if (name == nullptr) {
                _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m\n", "ptsname");
@@ -702,21 +715,6 @@ _vte_pty_open_posix(void)
                 return -1;
         }
 
-        /* Read the slave number and unlock it. */
-        if (grantpt(fd) != 0) {
-                vte::util::restore_errno errsv;
-                _vte_debug_print(VTE_DEBUG_PTY,
-                                 "%s failed: %s", "grantpt", g_strerror(errsv));
-                return -1;
-        }
-
-       if (unlockpt(fd) != 0) {
-                vte::util::restore_errno errsv;
-                _vte_debug_print(VTE_DEBUG_PTY,
-                                 "%s failed: %s", "unlockpt", g_strerror(errsv));
-                return -1;
-        }
-
        _vte_debug_print(VTE_DEBUG_PTY, "Allocated pty on fd %d.\n", (int)fd);
 
         return fd.steal();


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