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

H. Peter Anvin hpa at zytor.com
Wed Jun 11 07:50:12 PDT 2014


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



More information about the klibc mailing list