[klibc] [klibc:master] isatty(): use TCGETS instead of TIOCGPGRP, like dietlibc does

klibc-bot for Thorsten Glaser tg at mirbsd.org
Wed Jul 9 09:27:03 PDT 2014

Commit-ID:  7763dd33e5b8eed4b9e3c583c02c10176fd550d3
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=7763dd33e5b8eed4b9e3c583c02c10176fd550d3
Author:     Thorsten Glaser <tg at mirbsd.org>
AuthorDate: Wed, 11 Jun 2014 10:02:14 +0200
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Wed, 9 Jul 2014 08:21:02 -0700

[klibc] 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).

[ hpa: TCGETS matches glibc, so go with it ]

Reported-by: Dominik George <d.george at tarent.de>
Signed-off-by: Thorsten Glaser <t.glaser at tarent.de>
Signed-off-by: H. Peter Anvin <hpa at zytor.com>

 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);

More information about the klibc mailing list