linux-container: Do not rely on 'isatty?'.

This avoids problems where 'isatty?' return #t but 'ttyname' fails with
ENOTTY or such.

* gnu/build/linux-container.scm (mount-file-systems): Remove call of
'isatty?'.  Directly call 'ttyname' and catch 'system-error'.
master
Ludovic Courtès 2017-02-04 18:10:14 +01:00
parent e69dc54559
commit 168aba2978
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 11 additions and 5 deletions

View File

@ -128,13 +128,19 @@ for the process."
"/dev/fuse"))
;; Setup the container's /dev/console by bind mounting the pseudo-terminal
;; associated with standard input.
(let ((in (current-input-port))
(console (scope "/dev/console")))
(when (isatty? in)
;; associated with standard input when there is one.
(let* ((in (current-input-port))
(tty (catch 'system-error
(lambda ()
;; This call throws if IN does not correspond to a tty.
;; This is more reliable than 'isatty?'.
(ttyname in))
(const #f)))
(console (scope "/dev/console")))
(when tty
(touch console)
(chmod console #o600)
(bind-mount (ttyname in) console)))
(bind-mount tty console)))
;; Setup standard input/output/error.
(symlink "/proc/self/fd" (scope "/dev/fd"))