summary refs log tree commit diff stats
path: root/lib/system.nim
diff options
context:
space:
mode:
authornblaxall <43897322+nblaxall@users.noreply.github.com>2022-01-20 00:25:21 +1300
committerGitHub <noreply@github.com>2022-01-19 12:25:21 +0100
commit23c4bbedcbf12a7ab87baefe589b472837d89dbf (patch)
tree518dfecf796aeb8ddfb837ad9db66faf61e7e79e /lib/system.nim
parentb3c178c2024f679a83275f63ca9e21a8b5ba73d7 (diff)
downloadNim-23c4bbedcbf12a7ab87baefe589b472837d89dbf.tar.gz
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>
Diffstat (limited to 'lib/system.nim')
-rw-r--r--lib/system.nim9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 02da048e4..09de9fcde 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -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*()
.nim?h=devel&id=0ea4b71eec1fc2b738b203e4196f281be49d6aae'>0ea4b71ee ^
560a3bad2 ^


3ef146b0e ^
c0a3d4406 ^
e25474154 ^
c0a3d4406 ^
c25ffbf26 ^
b50133b50 ^
375c95d3a ^
560a3bad2 ^
99bcc233c ^
337e1ecc7 ^


28d9398de ^

3091bc495 ^
23ef565a3 ^
f25c638dc ^
e25474154 ^

c7b130b4e ^
38710b614 ^
e25474154 ^

3b7ef2288 ^
804e2ac89 ^
1d14cb1ad ^
48a62af3b ^
f44a4362b ^
804e2ac89 ^
2de98d9e0 ^
485c37194 ^
c7b130b4e ^
8d19a93f1 ^
132b6b3ef ^
da190876d ^

139562cc6 ^
f25c638dc ^







b5d833b32 ^
f25c638dc ^


38710b614 ^



b50133b50 ^
e25474154 ^



a6daf7152 ^
f25c638dc ^



38710b614 ^

f25c638dc ^


c0a3d4406 ^
f25c638dc ^
b50133b50 ^

0ea4b71ee ^

560a3bad2 ^


093af9b9e ^
3ef146b0e ^
6bc16904e ^
c0a3d4406 ^
3ef146b0e ^
d0de1fc33 ^

c0a3d4406 ^
c25ffbf26 ^
b50133b50 ^

375c95d3a ^
560a3bad2 ^
337e1ecc7 ^


5131b3cea ^
28d9398de ^

f25c638dc ^
23ef565a3 ^
e25474154 ^


c7b130b4e ^
38710b614 ^
f25c638dc ^
e25474154 ^
3b7ef2288 ^


1d14cb1ad ^
48a62af3b ^
f44a4362b ^
804e2ac89 ^
2de98d9e0 ^
485c37194 ^
8d19a93f1 ^
132b6b3ef ^

da190876d ^
139562cc6 ^
f25c638dc ^








b5d833b32 ^
f25c638dc ^



38710b614 ^



f25c638dc ^
e25474154 ^
92b8fac94 ^
e25474154 ^




8d734244b ^
e25474154 ^

8d734244b ^
92b8fac94 ^
8d734244b ^
e25474154 ^



922e216b8 ^
e25474154 ^
b50133b50 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187