mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 02:12:11 +00:00
add an example to setControlCHook (#19416)
* add an example to setControlCHook * [skip CI] format example for setControlCHook Co-authored-by: Nathan Blaxall <nathan.blaxall@actionstep.com>
This commit is contained in:
@@ -2319,6 +2319,15 @@ when notJSnotNims:
|
||||
proc setControlCHook*(hook: proc () {.noconv.})
|
||||
## Allows you to override the behaviour of your application when CTRL+C
|
||||
## is pressed. Only one such hook is supported.
|
||||
## Example:
|
||||
##
|
||||
## .. code-block:: Nim
|
||||
## proc ctrlc() {.noconv.} =
|
||||
## echo "Ctrl+C fired!"
|
||||
## # do clean up stuff
|
||||
## quit()
|
||||
##
|
||||
## setControlCHook(ctrlc)
|
||||
|
||||
when not defined(noSignalHandler) and not defined(useNimRtl):
|
||||
proc unsetControlCHook*()
|
||||
|
||||
Reference in New Issue
Block a user