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:
parent
b3c178c202
commit
23c4bbedcb
1 changed files with 9 additions and 0 deletions
|
|
@ -2319,6 +2319,15 @@ when notJSnotNims:
|
||||||
proc setControlCHook*(hook: proc () {.noconv.})
|
proc setControlCHook*(hook: proc () {.noconv.})
|
||||||
## Allows you to override the behaviour of your application when CTRL+C
|
## Allows you to override the behaviour of your application when CTRL+C
|
||||||
## is pressed. Only one such hook is supported.
|
## 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):
|
when not defined(noSignalHandler) and not defined(useNimRtl):
|
||||||
proc unsetControlCHook*()
|
proc unsetControlCHook*()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue