Repository navigation
Conversation
xterm-pty has to resort to ugly fiddling with emscripten's
internals in order to work. These changes attempt to
improve the situation.
* Port termios.ts from xterm-pty to JavaScript in library_termios.js
* Add `struct termios` to struct_info.json
* Push responsibility for handling ioctls to registered TTY devices.
TTYs are registered using `TTY.register(dev, ops)` where
`dev = FS.makedev(major, minor)` and `ops` contains tty-specific
operations. __syscall_ioctl now just gets the argument pointer and
delegates to FS.ioctl. FS.ioctl checks that the stream is a TTY
and delegates to stream.stream_ops.ioctl. TTY adds ioctl to its
stream_ops, and that does some checks before delegating to
stream.tty.ops.ioctl.
* ioctl on a TTY returns -ENOTTY if the stream is not a tty
and -EINVAL if the tty has no register ioctl function.
* Many TODO items remain
- Refactor FS and TTY so that default streams can be created with
user-defined TTY operations. Currently, #if !XTERMPTY
is used to choose the TTY ops in FS.createDefaultDevices.
- Ensure emscripten contribution guidelines and best practices
are followed.
- Ensure backwards compatiblity.
- Make sure ioctl return values are appropriate. When should
-EINVAL be used? When should -ENOTTY be used?
- Reduce boilerplate in ioctl functions. Does __syscall_ioctl
need to check `op` before delegating, or can it push
that to FS or TTY?
|
I think I'm going to need a fair amount of hand-holding when it comes to writing tests. While it should be possible to mock xterm-pty's TtyClient, it would be nice to have tests that include it. However, this would necessitate pulling in xterm.js and xterm-pty, which are both written in TypeScript and have their own builds, which doesn't feel right. The other thing on my mind is how this works (or doesn't work) with pthread and worker support. xterm-pty creates a worker and then sends it a SharedArrayBuffer. This doesn't play nice with emscripten's pthreads and workers. What this means is that programs using xterm.js + xterm-pty would be unable to use workers and pthreads without (at best) resorting to a lot of ugly trickery. I'm still thinking about how to handle that... |
As mentioned in #16352, xterm-pty has to resort to ugly fiddling with emscripten's internals in order to work. This is an attempt at rectifying that.