feat: implement IO::Tty/IO::Pty module with FFM native PTY bindings#498
Merged
feat: implement IO::Tty/IO::Pty module with FFM native PTY bindings#498
Conversation
Implement IO::Tty and IO::Pty as bundled Java modules using FFM (Foreign Function & Memory) native bindings for POSIX pseudo-terminal operations. Phases 1-7 of the implementation plan (dev/modules/io_pty.md): FFM PTY Bindings (Phase 1): - Add posix_openpt, grantpt, unlockpt, ptsname, setsid, ttyname, nativeOpen/Close/Read/Write/Dup, fcntlDupFd, ioctlWithPointer/Int, tcgetattr, tcsetattr to FFMPosixInterface/FFMPosixLinux - Platform-specific constants for macOS and Linux - UnsupportedOperationException stubs in FFMPosixWindows NativeFdIOHandle (Phase 2): - Bridge native POSIX file descriptors to PerlOnJava IOHandle interface - Implements fileno, sysread, syswrite, close, flush, eof IOTty.java Perlmodule (Phase 3): - pty_allocate, _open_tty, ttyname, pack/unpack_winsize XS replacements - Terminal constants in IO::Tty::Constant namespace - $IO::Tty::CONFIG platform capability string ioctl Upgrade (Phase 4): - Replace ioctl stub with real FFM-backed implementation - Handle TIOCGWINSZ/TIOCSWINSZ (struct), TIOCSCTTY (int) - Return "0 but true" for Perl convention Perl Shims (Phase 5): - IO/Tty.pm with set_raw, clone_winsize_from, get/set_winsize - IO/Pty.pm with new, slave, close_slave, make_slave_controlling_terminal - IO/Tty/Constant.pm with Exporter interface POSIX Module Additions (Phase 6): - Add isatty, setsid, ttyname, dup, close to POSIX.java - Implement POSIX::Termios class (new, getattr, setattr, get/set flags) - Add termios constants (ECHO, ICANON, TCSANOW, CS8, CSIZE, PARENB, VMIN, VTIME, and more) - Add termios_h export group to POSIX.pm Tests (Phase 7): - 8 test files (48 tests): constants, ttyname, slave, pty_set_raw, pty_destroy, pty_get_winsize, winsize, clone_winsize - All pass (2 TODO for native fd close semantics) Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Add IO::Tty, IO::Pty, IO::Tty::Constant to bundled-modules.md - Update io_pty.md checklist: all phases marked complete - Update progress tracking with dates, details, known limitations Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement IO::Tty and IO::Pty as bundled Java modules using FFM (Foreign Function & Memory) native bindings for POSIX pseudo-terminal operations.
What's included
FFM PTY Bindings
posix_openpt,grantpt,unlockpt,ptsname,setsid,ttyname,nativeOpen/Close/Read/Write/Dup,fcntlDupFd,ioctlWithPointer/Int,tcgetattr,tcsetattrUnsupportedOperationExceptionNativeFdIOHandle
IOTty.java Perlmodule
pty_allocate,_open_tty,ttyname,pack/unpack_winsizeXS replacementsIO::Tty::ConstantnamespaceReal ioctl implementation
TIOCGWINSZ,TIOCSWINSZ,TIOCSCTTYPerl shims
IO::Tty.pmwithset_raw,clone_winsize_from,get/set_winsizeIO::Pty.pmwithnew,slave,close_slave,make_slave_controlling_terminalIO::Tty::Constant.pmwith Exporter interfacePOSIX module additions
isatty,setsid,ttyname,dup,closePOSIX::Termiosclass withnew,getattr,setattr,get/setfor all flag fieldsECHO,ICANON,TCSANOW,CS8,CSIZE,PARENB,VMIN,VTIME, etc.Tests
Downstream impact
Expectmodule should install viajcpan install Expect(pure Perl, depends on IO::Pty)eval { require IO::Pty }will find it availableTest plan
makepasses (all unit tests, no regressions)IO::Pty->new,slave,isatty,set_raw,POSIX::TermiosGenerated with Devin