[PATCH] Terminal portability fixes for BSDs



Hello,

Antoine Jacoutot posted this patch to address some portability issues of
Nemiver on OpenBSD.  Below is his cover letter, as well as his patch
that I have amended to add a gnu-style ChangeLog to the commit log,
before applying it to the master branch.

Thank you, Antoine.

    There is no need to call grantpt(3) nor unlockpt(3), glibc's
    implementation of openpty(3) already call them and they are not
    needed/supported on OpenBSD which breaks the build.

    Use the BSD/POSIX-2001 compliant ttyname(3) function to get the name
    of the terminal instead of ptsname(3) which is not supported on
    OpenBSD.  We already have the slave fd so it doesn't matter.

>From bdf80c97eb216743c1702de5d6e710df0887e9c1 Mon Sep 17 00:00:00 2001
From: Antoine Jacoutot <ajacoutot gnome org>
Date: Thu, 21 Jun 2012 18:58:04 +0200
Subject: [PATCH] Terminal portability fixes for BSDs

	* src/uicommon/nmv-terminal.cc (Terminal::Priv::init_pty):
	Don't call useless grantpt and unlockpt.
	(Terminal::slave_pts_name): use POSIX call ttyname in lieu of
	the non-portable ptsname.
---
 src/uicommon/nmv-terminal.cc |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/uicommon/nmv-terminal.cc b/src/uicommon/nmv-terminal.cc
index 9eb0095..e925f67 100644
--- a/src/uicommon/nmv-terminal.cc
+++ b/src/uicommon/nmv-terminal.cc
@@ -263,16 +263,6 @@ struct Terminal::Priv {
         THROW_IF_FAIL (slave_pty);
         THROW_IF_FAIL (master_pty);
 
-        if (grantpt (master_pty)) {
-            LOG_ERROR ("oops");
-            return false;
-        }
-
-        if (unlockpt (master_pty)) {
-            LOG_ERROR ("oops");
-            return false;
-        }
-
         vte_terminal_set_pty (vte, master_pty);
         return true;
     }
@@ -311,12 +301,12 @@ Terminal::slave_pts_name () const
     THROW_IF_FAIL (m_priv);
     UString result;
 
-    if (!m_priv->master_pty) {
+    if (!m_priv->slave_pty) {
         LOG_ERROR ("oops");
         return result;
     }
 
-    result = ptsname (m_priv->master_pty);
+    result = ttyname (m_priv->slave_pty);
     return result;
 }
 
-- 
		Dodji


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