3 ms·
Terminal multiplexers like tmux need to create a pseudo-TTYs otherwise they couldn’t multiplex your terminal. My shell also creates PTYs on some rare occasions
by hnlmorg 3y ago
Terminal multiplexers like tmux need to create a pseudo-TTYs otherwise they couldn’t multiplex your terminal.
My shell also creates PTYs on some rare occasions too. I’d prefer not to because it’s messy but sometimes there’s no way around it if you want your command line applications to behave like they would on a TTY whilst still having your utility capture that applications output as if it were writing to a pipe.
This is a limitation of TTYs.
The most annoying part of it all is that creating a PTY differs from one Unix-like OS to another. So it’s definitely not a rabbit hole developers go down happily.
- kps 3y ago> Terminal multiplexers like tmux need to create a pseudo-TTYs otherwise they couldn’t multiplex your terminal. [Edit: I misread the parent comment as saying multiplexers needed to do terminal emulation. Dtach only multiplexes (using pesudo-TTYs, of course) but unlike screen or tmux does not do terminal emulation. Original comment follows:] That isn't strictly true; the one I use (dtach) is just a multiplexer.
- hnlmorg 3y agodtach creates pseudo-TTYs too: - https://github.com/crigler/dtach/blob/master/master.c#L53 https://github.com/crigler/dtach/blob/master/master.c#L53 - https://github.com/crigler/dtach/blob/master/master.c#L108 https://github.com/crigler/dtach/blob/master/master.c#L108 As an aside, that projects source is surprisingly easy to follow. I was able to grok it in just a couple of minutes. Kudos to the author.
- kps 3y agoYes, I misread your comment, sorry, having had my mind stuck on terminal emulation.
- hnlmorg 3y agoA PTY is an intrinsic part of terminal emulation. I think what you’re alluding to is that tmux gobbles up escape sequences (which is configurable by the way) and tracks cell positions. But as I said in another comment, the value add of tmux is its window management capabilities. That’s precisely why people like myself use it. And you cannot have that without complexity. In some edge cases that complexity causes issues, but on the whole I’m more productive for it. Saying it’s stupid that tmux does that is like saying it’s stupid that motorbikes have gears and fast patrol engines when a bmx works just as well. Sure, to someone who’s never seen a bike before they both look similar. But don’t be fooled by the fact that they both have 2 wheels because they cater to very different needs, hence their very different engineering designs.