Skip to content

Commit

Permalink
add an example to setControlCHook (#19416)
Browse files Browse the repository at this point in the history
* add an example to setControlCHook

* [skip CI] format example for setControlCHook

Co-authored-by: Nathan Blaxall <[email protected]>
  • Loading branch information
nblaxall and Nathan Blaxall authored Jan 19, 2022
1 parent b3c178c commit 23c4bbe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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*()
Expand Down

0 comments on commit 23c4bbe

Please sign in to comment.