emacs-devel
[Top][All Lists]
Advanced

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

a patch to make terminal-name to return actual terminal device


From: Daiki Ueno
Subject: a patch to make terminal-name to return actual terminal device
Date: Wed, 30 Apr 2008 17:32:02 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Hello,

I'm now trying to improve interactions between Emacs and gpg-agent, on
text-only consoles.  See the following post for detail.

From: Richard Stallman <address@hidden>
Subject: Fix needed for communication with gpg-agent
Date: Sat, 17 Feb 2007 15:57:37 -0500
Message-ID: <address@hidden>
http://article.gmane.org/gmane.emacs.devel/66490

The idea is simple: allow a child process (gpg-agent) to temporarily
access the controlling terminal of Emacs.  It can be done by passing the
actual device name (something like "/dev/pts/XX") to the child process.
However, I couldn't find any portable way to do this in Lisp level.  The
function terminal-name always returns "/dev/tty" on GNU/Linux.

So I'd like to propose a change of terminal-name to return the actual
device file name.  I'll attach a couple of files in this mail.  One is
the patch, and another is a test-case which directly interacts with
pinentry-curses (which is a subprogram used by gpg-agent), within Emacs.

In this patch, I assumed that terminal->name (in C) is only used for
informational purposes.  Please correct me if I am wrong.

diff --git a/configure.in b/configure.in
index 4740fb9..2285b58 100644
--- a/configure.in
+++ b/configure.in
@@ -2322,6 +2322,8 @@ AC_CHECK_FUNCS(getpt)
 # than to expect to find it in ncurses.
 AC_CHECK_LIB(ncurses, tparm)
 
+AC_CHECK_FUNCS(ttyname)
+
 # Do we have res_init, for detecting changes in /etc/resolv.conf?
 
 resolv=no
diff --git a/src/term.c b/src/term.c
index 4e63568..fe1edd0 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3351,7 +3351,16 @@ init_tty (char *name, char *terminal_type, int 
must_succeed)
 
     file = fdopen (fd, "w+");
     tty->name = xstrdup (name);
-    terminal->name = xstrdup (name);
+
+#if HAVE_TTYNAME
+    if (ctty)
+      {
+       char *ctty_name = ttyname (0);
+       terminal->name = xstrdup (ctty_name ? ctty_name : name);
+      }
+    else
+#endif
+      terminal->name = xstrdup (name);
     tty->input = file;
     tty->output = file;
   }

Attachment: pinentry-curses-test.el
Description: application/emacs-lisp

Regards,
-- 
Daiki Ueno

reply via email to

[Prev in Thread] Current Thread [Next in Thread]