|
|
|
|
|
by Joker_vD
90 days ago
|
|
Like [0] that Windows has for its console? This API has just recently finally lost to UNIX's in-line signaling, because the in-band controls can be proxied through almost anything, including literal serial line with two RX-TX wires and a common ground; the downside, of course, is that you have to build "out-of-line" signalling on your own. If getting the current cursor position in the terminal were as easy (and as fast) as calling GetConsoleScreenBufferInfo, instead of sending "\e[6n" to the terminal and then reading input from it and looking for "\e[(\d+);(\d+)R" inside and then somehow unreading the input before that device report, yeah, that'd be nice and would allow solving a lot of problems with mere brute force. Sadly, it is not, and so most reimplementations of e.g. readline/linenoise functionality in shells and prompts (Erlang's shell went through 2 internal reimplementations just in my time using it, for example) are flying blind, hoping that their implementation of wcwidth(3) matches the terminal's one. [0] https://learn.microsoft.com/en-us/windows/console/console-fu... |
|
What I personally have in mind is something very different-a terminal ioctl which gives you an fd which speaks a completely different protocol, such as JSON-RPC - or whatever else you prefer - to avoid endless disputes over which alternative protocol to use, it could be you pass the ioctl a string saying what alternative protocol you want, and it gives you an fd if the pty master has registered support for that protocol, an error otherwise. The “other fd” could actually be a Unix domain socket. This also means the kernel code change required would be minimal - it doesn’t have to actually understand the alternative protocol, just let the pty master register a mapping of protocol name strings to listening sockets.
> This API has just recently finally lost to UNIX's in-line signaling, because the in-band controls can be proxied through almost anything, including literal serial line with two RX-TX wires and a common ground; the downside, of course, is that you have to build "out-of-line" signalling on your own.
SSH/etc is totally capable of carrying “secondary channels” - that’s how it implements X11 forwarding, port forwarding, etc - admittedly would require some code change in SSH clients/servers but the change would be modest rather than massive.
The Windows approach can’t be so easily forwarded over the network because it is defined in terms of a C language API not a wire protocol. My idea doesn’t have that issue