Thorsten Glaser
2014-Jun-11 08:02 UTC
[klibc] [PATCH] isatty(): use TCGETS instead of TIOCGPGRP, like dietlibc does
While all ?real? ttys may support TIOCGPGRP, /dev/console doesn?t; using TCGETS here allows Linux booted with init=/bin/mksh-static to have working interactive command line (PS1, editing, etc). Reported-by: Dominik George <d.george at tarent.de> Signed-off-by: Thorsten Glaser <t.glaser at tarent.de> --- usr/klibc/isatty.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/klibc/isatty.c b/usr/klibc/isatty.c index c2e4a4e..2359479 100644 --- a/usr/klibc/isatty.c +++ b/usr/klibc/isatty.c @@ -8,8 +8,9 @@ int isatty(int fd) { - int dummy; + struct termios dummy; /* All ttys support TIOCGPGRP */ - return !ioctl(fd, TIOCGPGRP, &dummy); + /* except /dev/console which needs TCGETS */ + return !ioctl(fd, TCGETS, &dummy); } -- 2.0.0
H. Peter Anvin
2014-Jun-11 14:50 UTC
[klibc] [PATCH] isatty(): use TCGETS instead of TIOCGPGRP, like dietlibc does
On 06/11/2014 01:02 AM, Thorsten Glaser wrote:> While all ?real? ttys may support TIOCGPGRP, /dev/console doesn?t; > using TCGETS here allows Linux booted with init=/bin/mksh-static > to have working interactive command line (PS1, editing, etc). > > Reported-by: Dominik George <d.george at tarent.de> > Signed-off-by: Thorsten Glaser <t.glaser at tarent.de> > --- > usr/klibc/isatty.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/usr/klibc/isatty.c b/usr/klibc/isatty.c > index c2e4a4e..2359479 100644 > --- a/usr/klibc/isatty.c > +++ b/usr/klibc/isatty.c > @@ -8,8 +8,9 @@ > > int isatty(int fd) > { > - int dummy; > + struct termios dummy; > > /* All ttys support TIOCGPGRP */ > - return !ioctl(fd, TIOCGPGRP, &dummy); > + /* except /dev/console which needs TCGETS */ > + return !ioctl(fd, TCGETS, &dummy); > } >But is that really a tty, then? I also understand that virtio console doesn't support termios, which makes this an ugly bifurcation. All of this is stupid, of course... -hpa
Thorsten Glaser
2014-Jun-11 15:27 UTC
[klibc] [PATCH] isatty(): use TCGETS instead of TIOCGPGRP, like dietlibc does
H. Peter Anvin dixit:>But is that really a tty, then? I also understand that virtio consoleHm. Both eglibc and dietlibc return true for isatty on it.>doesn't support termios, which makes this an ugly bifurcation. All ofLet me test that? quick? hah not really (CONFIG_VIRTIO_CONSOLE=m)? ok luckily Ubuntu?s linux-image-3.15.0-5-generic is installable on Debian stable and has CONFIG_VIRTIO_CONSOLE=y? but no reiserfs module? gah? ok I could test it. This works. It has got enough of a tty for mksh-static linked against klibc to have proper command line editing even with console=hvc0.>this is stupid, of course...Fully agreed! bye, //mirabilos -- ?ah that reminds me, thanks for the stellar entertainment that you and certain other people provide on the Debian mailing lists ? sole reason I subscribed to them (I'm not using Debian anywhere) is the entertainment factor ? Debian does not strike me as a place for good humour, much less German admin-style humour?
Maybe Matching Threads
- [PATCH] isatty(): use TCGETS instead of TIOCGPGRP, like dietlibc does
- [PATCH] isatty(): use TCGETS instead of TIOCGPGRP, like dietlibc does
- [PATCH] isatty(): use TCGETS instead of TIOCGPGRP, like dietlibc does
- [PATCH] isatty(): use TCGETS instead of TIOCGPGRP, like dietlibc does
- [klibc:master] isatty(): use TCGETS instead of TIOCGPGRP, like dietlibc does