Skip to content

Commit 3302998

Browse files
Update design document with changes in signals handling (#49) (#53)
(cherry picked from commit 52836ef) Signed-off-by: Michael Orlov <michael.orlov@apex.ai> Co-authored-by: Michael Orlov <morlovmr@gmail.com>
1 parent 13072ac commit 3302998

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

docs/design/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,16 @@ and if this signal became unhandled current process will be terminated. \
108108
On POSIX compatible platforms keyboard handler will register it's own signal handler for the
109109
`SIGINT` to be able to return terminal input in canonical mode after abnormal program termination
110110
via pressing `Ctrl+C`. This signal handling could overlap with registered specific `SIGINT`
111-
handler on upper level or inside keyboard handler's clients. It could cause side effects and
112-
considering as current design and implementation limitations.
111+
handler on upper level or inside keyboard handler's clients. To avoid this overlap keyboard handler
112+
will save previous `SIGINT` handler and call it after processing its own signal handler. It will
113+
also restore the previous `SIGINT` handler in destructor. The keyboard handler constructor has an
114+
optional parameter `bool install_signal_handler` which by default is set to `true`. If this
115+
parameter is set to `false`, keyboard handler will not register its own `SIGINT` handler and
116+
will not restore previous `SIGINT` handler in destructor. This could be useful in cases when client
117+
code already registered its own `SIGINT` handler and don't want to overlap it with keyboard
118+
handler's one. In this case client code should be responsible for restoring terminal input in
119+
canonical mode after abnormal program termination via pressing `Ctrl+C` by calling static method
120+
`KeyboardHandler::restore_terminal_input_canonical_mode()`.
113121

114122
## Handling cases when client's code subscribed to the key press event got destructed before keyboard handler
115123
There are two options to properly handle this case:
@@ -241,4 +249,3 @@ issues:
241249
`F1..F12` and other control keys.
242250
- Windows implementation not able to detect `CTRL` + `ALT` + `key` combinations.
243251
- Windows implementation not able to detect `ALT` + `F1..12` keys.
244-

0 commit comments

Comments
 (0)