Using less in environment without controlling tty

Denys Vlasenko vda.linux at googlemail.com
Mon Aug 5 00:05:32 UTC 2013


On Mon, Aug 5, 2013 at 12:12 AM, Harald Becker <ralda at gmx.de> wrote:
>>>>Then try:
>>>>cmd | setsid sh -c 'exec >/dev/tty12 2>&1 ; exec less'
>>>
>>> NO!

First, stop yelling.

Second, what "NO"?
You were given an example how to give less a ctty.
This is not the only possible way to achieve that.
It's not like anyone forces you to use the given example.

>>> ... the cmd itself does fork, exec sh -c COMMAND, and pipe
>>> the data into stdin of the forked COMMAND. That is, after fork
>>> the first program is sh, so you can't use setsid as part of the
>>> COMMAND you give.
>>
>>I didn't understand this explanation.
>
> 'cmd' is a program which forks and exec sh -c COMMAND, where
> COMMAND is a string send to that program.

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?...)

> so if I send the command "setsid; exec ..." to my 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.

> it does:
>
> output of 'cmd' | sh -c 'setsid; exec ...'



>>Controlling tty concept exists for a reason.
>>It is a tty which has some control over the process in question.
>>
>>You don't want to have a controlling tty yet you want
>>to use that tty to control your process?
>
> No that is wrong! I do not want to let the tty 'control' my
> process in the sense of Unix process control. The only thinh I
> want, is the tty sending key codes, which get read and
> interpreted by my process. Meanwhile the process stays under
> control of a different tty, that is may be interrupted or
> stopped from that tty, not from the tty used to display
> messages.

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

-- 
vda


More information about the busybox mailing list