#sigint handling for a REPL

1 messages · Page 1 of 1 (latest)

violet blade
#

I'm trying to build out a small REPL, and would like to have it match the behavior of Python, Node, and most shells, where Ctrl-C (SIGINT) cancels the current input and re-prints the prompt, and Ctrl-D (end-of-file) exits the REPL. I note that Andrew doesn't like when programs catch SIGINT (https://github.com/ziglang/zig/pull/20644#issuecomment-2288018744), so is there any idiomatic way of getting the behavior I'm looking for?

(I'm still very new with Zig; this project is specifically for learning it, so forgive me if this is a silly question.)

fleet lagoon
#

Once the term is in raw mode you can just capture ctrl c/ctrl d as is