diff --git a/builtin.cpp b/builtin.cpp index d20dd27ea..3307431fb 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -2399,6 +2399,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv) } /* No autosuggestions in builtin_read */ reader_set_allow_autosuggesting(false); + reader_set_interruptible(true); reader_set_buffer(commandline, wcslen(commandline)); proc_push_interactive(1); diff --git a/reader.cpp b/reader.cpp index b7d531125..49030aded 100644 --- a/reader.cpp +++ b/reader.cpp @@ -580,10 +580,23 @@ static void reader_kill(size_t begin_idx, size_t length, int mode, int newv) } + +/* + Called from a signal handler, so make sure to check \c data exists. + This is in fact racey as there is no guarantee that \c *data's members are + written to memory before \c data is. But signal handling is currently racey + anyway, so this should be fixed together with the rest of the signal + handling infrastructure. +*/ +static bool get_interruptible() +{ + return data ? data->interruptible : false; +} + /* This is called from a signal handler! */ void reader_handle_int(int sig) { - if (!is_interactive_read) + if (!is_interactive_read || get_interruptible()) { parser_t::skip_all_blocks(); }