Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions prompt_toolkit/application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@

_SIGWINCH = getattr(signal, "SIGWINCH", None)
_SIGTSTP = getattr(signal, "SIGTSTP", None)
_SIGQUIT = getattr(signal, "SIGQUIT", None)


class Application(Generic[_AppResult]):
Expand Down Expand Up @@ -1010,6 +1011,21 @@ def run() -> None:

run_in_terminal(run)

def do_sigquit(self) -> None:
r"""
(Not thread safe -- to be called from inside the key bindings.)
Trigger SIGQUIT. Usually bound to ctrl-\.

(We need this because prompt_toolkit puts the terminal in raw mode, and
the TTY doesn't handle this signal anymore.)
"""
if _SIGQUIT is not None:

def run() -> None:
os.kill(os.getpid(), _SIGQUIT)

run_in_terminal(run, render_cli_done=True)

def print_text(
self, text: AnyFormattedText, style: Optional[BaseStyle] = None
) -> None:
Expand Down
7 changes: 7 additions & 0 deletions prompt_toolkit/shortcuts/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,13 @@ def _suspend(event: E) -> None:
"""
event.app.suspend_to_background()

@handle("c-\\")
def _do_sigquit(event: E) -> None:
"""
Trigger SIGQUIT.
"""
event.app.do_sigquit()

return kb

def prompt(
Expand Down