-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicitly handle control characters
The current SIGINT handler is not considered safe since it invokes functions that are not considered asynchronous safe[1]. Quoting the CERT C Coding Standard: In general, it is not safe to invoke I/O functions from within signal handlers. Instead, do not turn control characters into signal but instead handle the relevant ones explicitly. A pleasant side-effect is being able to test the Ctrl-C error path. While here, fix the broken suspend/resume behavior by resetting the initial terminal state prior suspending and re-read it upon resume. I do actually use suspend/resume while running pick when I forgot to check something that will affect the choice to select. [1] https://www.securecoding.cert.org/confluence/display/c/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers
- Loading branch information
Showing
4 changed files
with
58 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
description: Ctrl-C aborts without outputting the selected choice | ||
keys: \003 # CTRL_C | ||
exit: 1 | ||
stdin: | ||
a |