From b5d457b5cec33412a2d052e355720a514767364b Mon Sep 17 00:00:00 2001 From: Henrixounez <30901439+Henrixounez@users.noreply.github.com> Date: Mon, 4 Nov 2019 03:05:12 +0100 Subject: [PATCH] readline: catch siguser signal to reset tty --- vlib/readline/readline_linux.v | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vlib/readline/readline_linux.v b/vlib/readline/readline_linux.v index 0ab8b07c66..42b3541d29 100644 --- a/vlib/readline/readline_linux.v +++ b/vlib/readline/readline_linux.v @@ -35,6 +35,7 @@ enum Action { } // Toggle raw mode of the terminal by changing its attributes +// Catches SIGUSER (CTRL+C) Signal to reset tty fn (r mut Readline) enable_raw_mode() { if ( C.tcgetattr(0, &r.orig_termios) == -1 ) { r.is_tty = false @@ -53,7 +54,7 @@ fn (r mut Readline) enable_raw_mode() { } // Not catching the SIGUSER (CTRL+C) Signal -fn (r mut Readline) enable_raw_mode2() { +fn (r mut Readline) enable_raw_mode_nosig() { if ( C.tcgetattr(0, &r.orig_termios) == -1 ) { r.is_tty = false r.is_raw = false @@ -100,7 +101,7 @@ pub fn (r mut Readline) read_line_utf8(prompt string) ?ustring { r.previous_lines[0] = ''.ustring() } if !r.is_raw { - r.enable_raw_mode2() + r.enable_raw_mode() } print(r.prompt)