diff options
| author | Maxime Coste <mawww@kakoune.org> | 2023-05-29 20:25:56 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2023-05-29 20:25:56 +1000 |
| commit | 95a4d7037997d80f0ed9767b421653be819b6d28 (patch) | |
| tree | 2153e4ebea3231221581b208ff9e1260895d7db4 /src/shell_manager.cc | |
| parent | cf7c6380254c7c2733952d2899761a2afc881b44 (diff) | |
Kill current shell on <c-g> during shell execution
Closes #4907
Diffstat (limited to 'src/shell_manager.cc')
| -rw-r--r-- | src/shell_manager.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 96cfb063..62a60dc2 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -355,6 +355,7 @@ std::pair<String, int> ShellManager::eval( client.redraw_ifn(); }, EventMode::Urgent}; + bool cancelling = false; while (not terminated or child_stdin.write_fd() != -1 or ((flags & Flags::WaitForStdout) and (child_stdout.read_fd() != -1 or child_stderr.read_fd() != -1))) @@ -363,6 +364,11 @@ std::pair<String, int> ShellManager::eval( { EventManager::instance().handle_next_events(EventMode::Urgent, &orig_mask); } + catch (cancel&) + { + kill(pid, SIGINT); + cancelling = true; + } catch (runtime_error& error) { write_to_debug_buffer(format("error while waiting for shell: {}", error.what())); @@ -385,6 +391,9 @@ std::pair<String, int> ShellManager::eval( (size_t)full.count(), (size_t)spawn.count(), (size_t)wait.count())); } + if (cancelling) + throw cancel{}; + if (previous_status) // restore the status line { context.print_status(std::move(*previous_status)); |
