Using less in environment without controlling tty

Harald Becker ralda at gmx.de
Mon Aug 5 02:35:14 UTC 2013


Hi Denys !

>You were given an example how to give less a ctty.

I do not want to give less a ctty, to be able to display some
messages on an external tty.

>This is not the only possible way to achieve that.
>It's not like anyone forces you to use the given example.

The example does not work, or produce to much overhead for this
usage. A usage which may easily be achieved with one ore two
lines of code in Busybox less. Code which shall not break other
usage.

>I still understand nothing.
>Can you actually show the script instead of explaining it?
>I fail to understand the explanation ("send" to that program?
>what that means?...)

I already attached full source of command_buffer program to one
of my mails.

use it like:

{ echo "Any output"
  ...
  echo -e "\0377\0376\0020>|less\0"
} 2>&1 | console_buffer

But there are many other use cases of console_buffer, so I do not
want to change this program.

>If you send "setsid; exec ..." then you have no idea what you
>are doing. setsid requires an argument. "setsid;" will just show
>a help text.

Ok yes, I had been thinking about parameter less setsid() call in
C ... was quick answer ... the problem, setsid, will not work, if
called from within sh -c '...', you need to do setsid right
afeter forking, and here after fork a shell is invoked. So setsid
will not work.

>Is there any logical reason why you don't want to give
>a ctty to your less?

1) tty shall not be able to send signals, nor interrupt in any
way.

2) less shall stay under control of real ctty, so may be
interrupted at any time with Ctrl-C from there.

3) Your concept of ctty does not work in pid 1, with no /proc
& /sys, or just makes easy things unnecessary complex

Denys, I do not want to change how less works, I just want to be
able to give it a tty to display the messages without much
overhead in an environment without ctty. And all this is possible
without changing much code in less. So I do not understand, why
you insist on this ctty? I just don't want to have it. I do not
want to force anybody else to do something different, but I
won't be forced by someone else to do it in a specific way, when
it's possible to do it different without breaking other usage.

--
Harald


More information about the busybox mailing list