Skip to content

Commit

Permalink
Stop all threads and write ANSI-Reset on Ctrl-C
Browse files Browse the repository at this point in the history
On Ctrt-C stop all threads currently writing to the terminal, ignoring
whatever they have locked, and write the ANSI-Reset code directly
to the terminal, then exit.

This uses `pthread_kill()` or `SuspendThread()`, then `libc::write()`
or `WriteConsoleA()` on Unix or Windows, respectively.
  • Loading branch information
th1000s committed Feb 1, 2024
1 parent 9b42af9 commit b0323c7
Show file tree
Hide file tree
Showing 6 changed files with 444 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ serde_json = "1.0.23"
termcolor = "1.1.0"
textwrap = { version = "0.16.0", default-features = false }

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3.9", features = ["handleapi"] }

[target.'cfg(not(target_os = "windows"))'.dependencies]
libc = "0.2.151"

[target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.jemallocator]
version = "0.5.0"

Expand Down
Loading

0 comments on commit b0323c7

Please sign in to comment.