Using less in environment without controlling tty

Laurent Bercot ska-dietlibc at
Sat Jul 27 03:42:04 UTC 2013

> And how is the data pipe to fd 3? The intention is to pipe all
> messages to stdin of the invoked program. This is the way normal
> pipes work. So this would need heavy fiddling with the file
> descriptor redirecting. Very hard to do in shell programming and
> very much overhead to just open a device for display?

 Ah, I was assuming you had full control on console_buffer,
which is for instance a C program. If you only have access to
executables and shell commands, yes, it is more complicated.
 Shameless plug: execline makes opening anonymous pipes and
redirecting fds much easier than the shell does.

> Which tests? ... and how are you able to burn your system, other
> than you are always able (like cat >ANYWHERE)?

 Oh, I just meant that termios would fail and since the return
codes are not tested (because they are assumed to work at this point)
less would just do ugly things. Nothing too serious.

> And what about
> original less, it seams it doesn't have the problem on
> using /dev/tty ... I'm able to load original less in this
> situation to display the messages without problems
> ( "|/usr/bin/less >/dev/ttyN" ), but this needs the availability
> of less (and libraries) which are not available on initial steps
> of startup. So why does Busybox less needs extra tests, not
> required for original less?

 isatty(1) should be enough indeed. No idea why busybox does
things differently.


More information about the busybox mailing list