Pressing Ctrl-C killed the harness. cbreak() leaves ISIG on, so the terminal driver turned the key into SIGINT and the process died before wgetch() could return 3 - the 'Ctrl-C cancels' line was a claim, and one keystroke disproved it. raw() hands every byte to the program. Cancelling a turn also only took effect between steps, so a request in flight kept running to completion. The transport used popen(), which returns a stream and not a process id, so there was nothing to kill. It now forks and execs, keeps the pid, and both the read loop and the streaming loop poll with a 200 ms timeout and SIGKILL the child when the turn is cancelled. Measured: Ctrl-C during a streaming request returns to the prompt in 510 ms and the UI survives. Temp files no longer use a fixed /tmp path: $TMPDIR, then /var/tmp. Three sites, including the cli plugin, and they carry the conversation, so the path is now a 512-byte buffer built at runtime instead of a literal.
88 KiB
Executable File
88 KiB
Executable File