Skip to content

Commit

Permalink
add an example to setControlCHook (nim-lang#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
2 people authored and PMunch committed Mar 28, 2022
1 parent 7e5fb1e commit a979893
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 a979893

Please sign in to comment.