diff --git a/src/shell_manager.cc b/src/shell_manager.cc index 96cfb063c..62a60dc29 100644 --- a/src/shell_manager.cc +++ b/src/shell_manager.cc @@ -355,6 +355,7 @@ std::pair 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 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 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));