From: Daiki Ueno <ueno@unixuser.org>
To: emacs-devel@gnu.org
Subject: a patch to make terminal-name to return actual terminal device
Date: Wed, 30 Apr 2008 17:32:02 +0900 [thread overview]
Message-ID: <877ief7ngd.fsf@broken.deisui.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]
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 <rms@gnu.org>
Subject: Fix needed for communication with gpg-agent
Date: Sat, 17 Feb 2007 15:57:37 -0500
Message-ID: <E1HIWcj-0002DU-Cw@fencepost.gnu.org>
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ttyname.diff --]
[-- Type: text/x-diff, Size: 879 bytes --]
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 #3: pinentry-curses-test.el --]
[-- Type: application/emacs-lisp, Size: 923 bytes --]
[-- Attachment #4: Type: text/plain, Size: 25 bytes --]
Regards,
--
Daiki Ueno
next reply other threads:[~2008-04-30 8:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-30 8:32 Daiki Ueno [this message]
2008-04-30 9:37 ` a patch to make terminal-name to return actual terminal device Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877ief7ngd.fsf@broken.deisui.org \
--to=ueno@unixuser.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).