+ process
+ terminal-name
+ agent-file
+ (agent-mtime '(0 0 0 0)))
+ ;; Set GPG_TTY and TERM for pinentry-curses. Note that we can't
+ ;; use `terminal-name' here to get the real pty name for the child
+ ;; process, though /dev/fd/0" is not portable.
+ (unless (memq system-type '(ms-dos windows-nt))
+ (with-temp-buffer
+ (condition-case nil
+ (when (= (call-process "tty" "/dev/fd/0" t) 0)
+ (delete-char -1)
+ (setq terminal-name (buffer-string)))
+ (file-error))))
+ (when terminal-name
+ (setq process-environment
+ (cons (concat "GPG_TTY=" terminal-name)
+ (cons "TERM=xterm" process-environment))))
+ ;; Record modified time of gpg-agent socket to restore the Emacs
+ ;; frame on text terminal in `epg-wait-for-completion'.
+ ;; See
+ ;; <http://lists.gnu.org/archive/html/emacs-devel/2007-02/msg00755.html>
+ ;; for more details.
+ (when (and agent-info (string-match "\\(.*\\):[0-9]+:[0-9]+" agent-info))
+ (setq agent-file (match-string 1 agent-info)
+ agent-mtime (or (nth 5 (file-attributes agent-file)) '(0 0 0 0))))