# mdt console — SIGWINCH Self-Pipe Pattern (coral.googlesource.com) ## Metadata | Field | Value | |---|---| | Institute | Molodetz Institute — Research & Retrieval Division | | Subject | shell-multiplexer-auto-attach | | Document type | Source Dossier | | Tier | 1 | | Source title | console: Add in SIGWINCH support | | Source URL | https://coral.googlesource.com/mdt/+/d5b37aa3c97daf3e29b0aeacfce1c5d3beb1dff8%5E%21/ | | Source publisher / author | Google Coral (mdt project) | | Source type | repository | | Source date (published) | Unknown — not stated | | Date researched | 2026-10-09 | | Researched by | tai (agent), model: Claude Sonnet 5, on behalf of retoor | | Research method | web search synthesis | | Confidence | Medium | | Status | Active | ## Summary A commit adding SIGWINCH support to Google's `mdt` console tool, using the standard "signal handler just sets a flag (or writes to a self-pipe); the real work happens in the main loop" pattern — the handler itself never calls the ioctl or touches shared state directly. ## Key findings - Signal handlers should do the absolute minimum (set a flag / write one byte to a self-pipe) because most libc/syscall operations are not safe to call from inside a signal handler; the actual `TIOCGWINSZ` read and any forwarding happens back in the normal event loop once it notices the flag/pipe-byte. ## Pros / strengths - A real, shipped example of the "minimal signal handler, defer the work" discipline applied specifically to SIGWINCH, in Python-adjacent/C-level console tooling from a credible engineering org. ## Cons / limitations / caveats - Specific to `mdt`'s own event-loop shape; the general principle (minimal handler, deferred work) transfers, the exact code structure doesn't. ## Relevance to tai If tai ever writes its own `SIGWINCH` handler (e.g. in a thin Python control process around tmux), it must follow this exact discipline — `signal.signal(signal.SIGWINCH, lambda *a: flag.set())` and do the real `ioctl`/forwarding work in the main loop, never inside the handler itself. ## Changelog | Date | Change | |---|---| | 2026-10-09 | Initial dossier created. |