Skip to content

Enable termios stdlib module (terminal I/O control) #302

@ppenna

Description

@ppenna

Summary

Enable the termios C extension module, which provides POSIX terminal I/O control.

Current State

Commented out in Modules/Setup.stdlib:

#termios termios.c

Why Enable It

  • tty module depends on termios for raw/cbreak mode
  • getpass.getpass() uses termios to disable echo for password input
  • readline module integration depends on terminal attribute control
  • Interactive Python REPL terminal handling
  • Required for proper signal handling in terminal applications

Work Required

  1. Uncomment in Modules/Setup.stdlib:
    termios termios.c
    
  2. Nanvix POSIX API requirements:
    • tcgetattr(fd, termios_p) — get terminal attributes
    • tcsetattr(fd, optional_actions, termios_p) — set terminal attributes
    • tcsendbreak(fd, duration) — send break
    • tcdrain(fd) — wait for output to drain
    • tcflush(fd, queue_selector) — flush terminal I/O
    • tcflow(fd, action) — suspend/resume terminal I/O
    • cfgetispeed() / cfgetospeed() — get baud rates
    • cfsetispeed() / cfsetospeed() — set baud rates
  3. Required headers: <termios.h>, <sys/ioctl.h>
  4. Terminal ioctls needed: TIOCGWINSZ (get window size) — used by os.get_terminal_size()
  5. Build and test: python -c "import termios; print(termios.B9600)"

POSIX API Dependencies

API Purpose
tcgetattr() Get terminal attributes
tcsetattr() Set terminal attributes
tcdrain() Wait for output drain
tcflush() Flush I/O queues
tcflow() Suspend/resume I/O
cfget/setispeed() Baud rate control

Complexity

Medium — requires Nanvix terminal subsystem to support termios APIs.

Source Files

  • Modules/termios.c

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions