bytecodealliance/rustix

Add support for `openpty`

kchibisov opened this issue · 3 comments

I think it's the only thing left to use rustix instead of nix in alacritty_terminal crate. Given that termios is already provided it should be straight forward.

openpty is a little tricky because it's not a single syscall on Linux. It's about 4 to 6 syscalls. Rustix usually tries to avoid higher-level APIs like this.

From a brief survey, I think an approach like this might make sense:

  • Rustix could add a rusix::pty which contains openpt, ptsname, unlockpt, grantpt, and ioctl_tiocgptpeer functions, on platforms where they can be supported.
  • There could be a new separate crate that provides an openpty-like API which is backed by rustix's openpt/ptsname/ioctl_tiocgptpeer/unlockpt/openat/tcsetwinsize/tcsetattr on Linux and backed by libc::openpty on other platforms.

I've now posted #673 adding support for openpt et al in rustix, and I created a rustix-openpty repo with a simple implementation of an openpty function that uses it, here: https://github.com/sunfishcode/rustix-openpty

Thanks!