You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ Supports Windows, Linux and Mac OS X.
8
8
To catch Ctrl+C event/signal you should call:
9
9
10
10
unsigned int CtrlCLibrary::SetCtrlCHandler(std::function<bool(enum CtrlSignal)> handler);
11
+
11
12
handler - custom handler;
12
13
13
14
**Return**:
@@ -16,7 +17,8 @@ Returns handler identifier, or CtrlCLibrary::kErrorID in case of error.
16
17
To remove handler you should call:
17
18
18
19
void CtrlCLibrary::ResetCtrlCHandler(unsigned int id);
19
-
id - handler identifier, returned by CtrlCLibrary::SetCtrlCHandler.
20
+
21
+
id - handler identifier, returned by CtrlCLibrary::SetCtrlCHandler.
20
22
21
23
### Installing
22
24
@@ -38,23 +40,22 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
38
40
## Notes
39
41
40
42
You can add a few handlers for Ctrl+C processing. All handlers will be called in LIFO order: first added handler will be called at last.
41
-
Each handler should return bool value:
42
-
43
+
Each handler should return bool value:
43
44
**true* - to stop processing by other handlers;
44
45
**false* - to continue processing by other handlers (also, see notes for Windows below).
45
46
46
-
Library is thread-safe. *Warning*: You shouldn't remove handler from handler code. It will cause deadlock.
47
+
The functions to set, reset and handle event are thread-safe.*Warning*: You shouldn't remove handler from handler code. It will cause deadlock.
47
48
48
-
####Errors####
49
+
####Errors
49
50
Adding a new handler can return error id (kErrorID) in case of system error or lack of memory.
50
51
51
-
####Exceptions####
52
-
The code process its errors (and any bad_alloc into SetCtrlCHandler call). In this case it will return error identifier (kErrorID).
52
+
####Exceptions
53
+
The code processes its errors (and any bad_alloc into SetCtrlCHandler call). In this case it will return error identifier (kErrorID).
53
54
Other exceptions aren't processed - you should catch them by your code.
54
55
55
-
####Linux notes####
56
-
Adding any handler will cause a previous handler will not work. If first adding caused error, previous handler will not work too - OS will use DEFAULT handler.
57
-
Removing of all handlers causes setting DEFAULT handler for Ctrl+C.
56
+
####Linux and Mac OS X notes
57
+
Setting any handler will cause a previous handler will not work. If first setting causes error, previous handler will not work too - OS will use DEFAULT handler.
58
+
Removing of all handlers causes set DEFAULT handler for Ctrl+C.
58
59
59
-
#### Windows notes####
60
+
#### Windows notes
60
61
If all handlers return **false**, a previous handler will be called. It can be default OS handler and your process will be closed.
0 commit comments