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:
nblaxall
2022-01-20 00:25:21 +13:00
committed by GitHub
parent b3c178c202
commit 23c4bbedcb

View File

@@ -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*()