From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daiki Ueno Newsgroups: gmane.emacs.devel Subject: a patch to make terminal-name to return actual terminal device Date: Wed, 30 Apr 2008 17:32:02 +0900 Message-ID: <877ief7ngd.fsf@broken.deisui.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1209544346 3050 80.91.229.12 (30 Apr 2008 08:32:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 30 Apr 2008 08:32:26 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 30 10:33:02 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jr7kK-0005hR-RL for ged-emacs-devel@m.gmane.org; Wed, 30 Apr 2008 10:33:01 +0200 Original-Received: from localhost ([127.0.0.1]:37565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jr7je-0008IC-1s for ged-emacs-devel@m.gmane.org; Wed, 30 Apr 2008 04:32:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jr7jX-0008GS-KO for emacs-devel@gnu.org; Wed, 30 Apr 2008 04:32:11 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jr7jU-0008Dd-89 for emacs-devel@gnu.org; Wed, 30 Apr 2008 04:32:09 -0400 Original-Received: from [199.232.76.173] (port=45393 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jr7jU-0008DM-3G for emacs-devel@gnu.org; Wed, 30 Apr 2008 04:32:08 -0400 Original-Received: from py-out-1112.google.com ([64.233.166.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jr7jT-0000fv-Ft for emacs-devel@gnu.org; Wed, 30 Apr 2008 04:32:07 -0400 Original-Received: by py-out-1112.google.com with SMTP id u52so409116pyb.1 for ; Wed, 30 Apr 2008 01:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date:message-id:user-agent:mime-version:content-type:sender; bh=ev8tFxX9XqfqxoghfC3rfL8TC4jIn8JI6IpHHFY1ObE=; b=btXcOmhNjfFMdSU+35h5K4jpqbi6AEBJkJMN7ybasuzLUZc8LDeP6Cui/3EqFOJec3E6cGKWyn7AQcvLAQcKs28UJPNIiyLPJeCD/fmJELS5W15tqO6UfTpBN+6QEfhYzLfOUfy+Nq215JfmIR1ftWPfPJn/FIqMOA780oLaBmY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:user-agent:mime-version:content-type:sender; b=KoLGSMQ7PKn0T1Kd8D5Gf8fDOBPZwN5ru6ehegmLnv1aPIkFpvEd1NBGvxRki3eVyaIig2IgjWHBSwtvIstciIm0OaH4TTfpNNRvJvFibjMrN63rhZKHV5ryXS7Xv4iHA5FUZzXPaZgwJlmpG9g5U9P+BSYm3mX4xCY9+YBT73M= Original-Received: by 10.141.101.15 with SMTP id d15mr179344rvm.249.1209544325951; Wed, 30 Apr 2008 01:32:05 -0700 (PDT) Original-Received: from p360 ( [150.82.173.253]) by mx.google.com with ESMTPS id k2sm593601rvb.4.2008.04.30.01.32.04 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 30 Apr 2008 01:32:04 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:96207 Archived-At: --=-=-= 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 Subject: Fix needed for communication with gpg-agent Date: Sat, 17 Feb 2007 15:57:37 -0500 Message-ID: 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=ttyname.diff 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; } --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=pinentry-curses-test.el ;; M-x pinentry-curses-test (defun pinentry-curses-send-command (process command) (save-excursion (set-buffer buffer) (erase-buffer) (process-send-string process command) (while (and (eq (process-status process) 'run) (not (progn (goto-char (point-max)) (looking-back "^\\(OK\\|ERR .*\\)\n")))) (accept-process-output process 0.1)))) (defun pinentry-curses-test () (interactive) (unwind-protect (let* ((buffer (generate-new-buffer "pinentry")) (process (start-process "pinentry" buffer "pinentry-curses")) (inhibit-redisplay t)) (pinentry-curses-send-command process (format "OPTION ttyname=%s\n" (terminal-name))) (pinentry-curses-send-command process (format "OPTION ttytype=%s\n" (tty-type))) (pinentry-curses-send-command process "GETPIN\n") (kill-process process)) (redraw-frame (selected-frame)))) --=-=-= Regards, -- Daiki Ueno --=-=-=--