Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Korsgaard <peter@korsgaard.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] fs/cpio/init: unbreak ttyname_r() on glibc after dropping /dev/console exec
Date: Sat, 29 Aug 2020 15:40:53 +0200	[thread overview]
Message-ID: <87mu2din8a.fsf@dell.be.48ers.dk> (raw)
In-Reply-To: <20200829132405.GE14354@scaer> (Yann E. MORIN's message of "Sat,  29 Aug 2020 15:24:05 +0200")

>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

Hi,

 >> +# use the /dev/console device node from devtmpfs if possible to not
 >> +# confuse glibc's ttyname_r().
 >> +# This may fail (E.G. booted with console=), and errors from exec will
 >> +# terminate the shell, so use a subshell for the test
 >> +if (exec 0</dev/console) 2>/dev/null; then
 >> +    exec 0</dev/console
 >> +    exec 1>/dev/console
 >> +    exec 2>/dev/console
 >> +fi

 > You forgot the else part, which should redirect to /dev/null, so that we
 > do have valid fds in the case /dev/console does not really exist, no?

Well, the kernel already takes care of that since commit 2bd3a997befc2
(E.G. as explained by buildroot commit 98a6f1fc02e41), so I am not sure
what explicitly reopening /dev/null would achive?

ttyname_r() / tty already returns ENOENT (not a tty) for this case
without reopening /dev/null:

tty </dev/null
not a tty

-- 
Bye, Peter Korsgaard

  reply	other threads:[~2020-08-29 13:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-29 13:09 [Buildroot] [PATCH] fs/cpio/init: unbreak ttyname_r() on glibc after dropping /dev/console exec Peter Korsgaard
2020-08-29 13:24 ` Yann E. MORIN
2020-08-29 13:40   ` Peter Korsgaard [this message]
2020-08-29 14:43 ` Yann E. MORIN
2020-08-29 17:40 ` Peter Korsgaard

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mu2din8a.fsf@dell.be.48ers.dk \
    --to=peter@korsgaard.com \
    --cc=buildroot@busybox.net \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox