On 27/10/2025 20:29, Chet Ramey wrote:
This is the part I don't get. It's not bash that sets the shell to raw
mode, since there's not a tty in the mix, so it must be something in how
it's invoked, or another program that sets the terminal modes and then
execs bash.

In my setup when invoking `ssh -q -o ControlPath=none -tt -o "RemoteCommand=bin/sh -i" <host>` seems to be creating a tty and that tty is also set to canonical mode. If I then feed it two nested shells it looses output. A simple example of this is:

```
/bin/sh --noediting -i
/bin/sh --noediting -c 'cat -'
Lorem ipsum ...
```

Then some amount of the sent data which should be printed by the `cat` gets lost. Throwing in some `stty`'s here and there seems to reveal that the tty does actually remain in canonical mode when the subshells are invoked, so I'm actually a bit confused why there are problems here.

I did also place an `strace -e read,ioctl` on the first subshell, and it essentially shows two consecutive lines:

```
ioctl(255, TCGETS, {opost isig icanon echo ...}) = 0
read(0, "/bin/sh --noediting -c 'cat -'\nLorem ipsum...", 128) = 128
```

Based on this it seems like the middle shell is performing the read-ahead. It also seems like the TTY should probably be in the correct state. Though I'm not entirely sure if the fd `255` corresponds to the right one. It could also be an issue with the pseudo-terminal allocated by ssh.

Removing the middle shell also makes the problem go away.

I will need to do some more poking around. I'd welcome any other ideas for things to try.

Thanks,
Rudi

Reply via email to