[PATCH 5/7] cttyhack: serial console detection is Linux-specific

Denys Vlasenko vda.linux at googlemail.com
Fri Jul 30 00:44:47 UTC 2010


On Thursday 29 July 2010 04:29, Jeremie Koenig wrote:
> ---
>  shell/cttyhack.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/shell/cttyhack.c b/shell/cttyhack.c
> index a80d49d..aaff29a 100644
> --- a/shell/cttyhack.c
> +++ b/shell/cttyhack.c
> @@ -13,7 +13,6 @@
>  //config:config CTTYHACK
>  //config:	bool "cttyhack"
>  //config:	default y
> -//config:	depends on PLATFORM_LINUX
>  //config:	help
>  //config:	  One common problem reported on the mailing list is "can't access tty;
>  //config:	  job control turned off" error message which typically appears when
> @@ -112,13 +111,19 @@ int cttyhack_main(int argc UNUSED_PARAM, char **argv)
>  		close(fd);
>  	} else {
>  		/* We don't have ctty (or don't have "/dev/tty" node...) */
> -		if (ioctl(0, TIOCGSERIAL, &u.sr) == 0) {
> +		if (0) {}
> +#ifdef TIOCGSERIAL
> +		else if (ioctl(0, TIOCGSERIAL, &u.sr) == 0) {
>  			/* this is a serial console */
>  			sprintf(console + 8, "S%d", u.sr.line);
> -		} else if (ioctl(0, VT_GETSTATE, &u.vt) == 0) {
> +		}
> +#endif
> +#ifdef __linux__
> +		else if (ioctl(0, VT_GETSTATE, &u.vt) == 0) {
>  			/* this is linux virtual tty */
>  			sprintf(console + 8, "S%d" + 1, u.vt.v_active);
>  		}
> +#endif
>  		if (console[8]) {
>  			fd = xopen(console, O_RDWR);
>  			//bb_error_msg("switching to '%s'", console);

Looks like after this cttyhack will build on !Linux, yes,
but will be basically useless: both #ifdefs will be skipped,
and thus it will never detect tty's type.

Does it make sense to create such formally working, but useless
applets? (Maybe yes, in the name of script compatibility...)

What do you think?
-- 
vda


More information about the busybox mailing list