[vte] pty: Remove openpty code path



commit 0e08c0961ef6938c2b35564ce3543a02eb472e20
Author: Christian Persch <chpe gnome org>
Date:   Sun Dec 13 19:08:23 2015 +0100

    pty: Remove openpty code path
    
    Apparently all the BSDs do posix_openpt now, so there's no need for
    a separate codepath using openpty() anymore.

 configure.ac    |   15 ++-------------
 src/Makefile.am |    1 -
 src/pty.cc      |   46 ----------------------------------------------
 3 files changed, 2 insertions(+), 60 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 03484e8..45d61a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -261,19 +261,8 @@ AC_HEADER_TIOCGWINSZ
 
 # Check for how to open a new PTY. We support posix_openpt and BSDs openpty
 
-LIBUTIL=
-AC_CHECK_FUNCS([posix_openpt grantpt unlockpt ptsname],[],[
-   # Try BSD
-   AC_SEARCH_LIBS([openpty],[util],[have_openpty=yes],
-   [AC_MSG_ERROR([have neither UNIX98 PTY nor BSD openpty])])
-
-   if test "$ac_cv_search_openpty" != "none required"; then
-     LIBUTIL="$ac_cv_search_openpty"
-   fi
-   AC_DEFINE(HAVE_OPENPTY,1,[Define if you have the openpty function.])
-])
-
-AC_SUBST([LIBUTIL])
+AC_CHECK_FUNCS([posix_openpt grantpt unlockpt ptsname],[],
+  [AC_MSG_ERROR([no support for Unix98 PTY found])])
 
 # Misc PTY handling functions
 AC_CHECK_FUNCS([cfmakeraw fork setsid setpgid getpgid tcgetattr tcsetattr])
diff --git a/src/Makefile.am b/src/Makefile.am
index 67b291a..56d887a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -128,7 +128,6 @@ libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_LDFLAGS = \
        $(AM_LDFLAGS)
 
 libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_LIBADD = \
-       $(LIBUTIL) \
        $(VTE_LIBS)
 
 # Try hard to avoid linking to libstd++ by using the C linker instead of the C++ linker
diff --git a/src/pty.cc b/src/pty.cc
index 1fb2660..d2ca55b 100644
--- a/src/pty.cc
+++ b/src/pty.cc
@@ -73,10 +73,6 @@
 #define NSIG (8 * sizeof(sigset_t))
 #endif
 
-#if defined(HAVE_POSIX_OPENPT) && defined(HAVE_GRANTPT) && defined(HAVE_UNLOCKPT)
-#define HAVE_UNIX98_PTY
-#endif
-
 #define VTE_VERSION_NUMERIC ((VTE_MAJOR_VERSION) * 10000 + (VTE_MINOR_VERSION) * 100 + (VTE_MICRO_VERSION))
 
 #if !GLIB_CHECK_VERSION(2, 42, 0)
@@ -150,7 +146,6 @@ 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");
@@ -161,7 +156,6 @@ vte_pty_child_setup (VtePty *pty)
                 _vte_debug_print(VTE_DEBUG_PTY, "%s failed: %m", "unlockpt");
                 _exit(127);
         }
-#endif
 
        char *name = ptsname(masterfd);
         if (name == nullptr) {
@@ -590,8 +584,6 @@ fd_setup(int fd)
         return 0;
 }
 
-#if defined(HAVE_UNIX98_PTY)
-
 /*
  * _vte_pty_open_posix:
  * @pty: a #VtePty
@@ -657,38 +649,6 @@ _vte_pty_open_posix(void)
         return fd.steal();
 }
 
-#elif defined(HAVE_OPENPTY)
-
-/*
- * _vte_pty_open_bsd:
- * @pty: a #VtePty
- * @error: a location to store a #GError, or %NULL
- *
- * Opens new file descriptors to a new PTY master and slave.
- *
- * Returns: the new PTY's master FD, or -1
- */
-static int
-_vte_pty_open_bsd(void)
-{
-        vte::util::smart_fd parentfd, childfd;
-       if (openpty(parentfd, childfd, NULL, NULL, NULL) != 0) {
-                vte::util::restore_errno errsv;
-                _vte_debug_print(VTE_DEBUG_PTY,
-                                 "%s failed: %s", "openpty", g_strerror(errsv));
-               return -1;
-       }
-
-        if (fd_setup(parentfd) < 0)
-                return -1;
-
-       return parentfd.steal();
-}
-
-#else
-#error Have neither UNIX98 PTY nor BSD openpty!
-#endif /* HAVE_UNIX98_PTY */
-
 static int
 _vte_pty_open_foreign(int masterfd /* consumed */)
 {
@@ -798,13 +758,7 @@ vte_pty_initable_init (GInitable *initable,
         if (priv->foreign) {
                 priv->pty_fd = _vte_pty_open_foreign(priv->pty_fd);
         } else {
-#if defined(HAVE_UNIX98_PTY)
                 priv->pty_fd = _vte_pty_open_posix();
-#elif defined(HAVE_OPENPTY)
-                priv->pty_fd = _vte_pty_open_bsd();
-#else
-#error Have neither UNIX98 PTY nor BSD openpty!
-#endif
         }
 
         if (priv->pty_fd == -1) {


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