Files
micropython/tests/cmdline
Andrew Leech 30781dce0a tests/cmdline: Add Ctrl-C interrupt test for the repl_ test framework.
Adds a "# sigint:" directive for repl_ tests that need Ctrl-C to
generate SIGINT via the PTY terminal driver. When present, the child
process is set up with the PTY as its controlling terminal (via
setsid/TIOCSCTTY/tcsetpgrp) so that \x03 written to the PTY master
generates SIGINT for the child's process group.

This works because MicroPython's REPL restores original terminal
settings (with ISIG enabled) before executing user code, allowing the
terminal driver to convert \x03 into SIGINT during blocking operations.

Test added:
- repl_ctrl_c_interrupt_execution.py: Verifies Ctrl-C interrupts a
  blocking time.sleep() call and the REPL remains functional afterward.

Also wraps PTY fd handling in try/finally for all repl_ tests.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2026-05-08 00:45:58 +10:00
..