Skip to content

Commit 36042bf

Browse files
committed
Start writing the Readme
1 parent c740175 commit 36042bf

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Readme.adoc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
= XcodeTools
2+
François Lamboley <francois[email protected]>
3+
4+
== Example of Use
5+
6+
I believe good examples are worth thousands of words.
7+
8+
Example of a simple traditional sigaction handler, using Swift syntax:
9+
10+
[source,swift]
11+
----
12+
let action = Sigaction(handler: .ansiC({ sigID in
13+
logger.debug("Handling signal \(Signal(rawValue: sigID)) from sigaction")
14+
}))
15+
try action.install(on: .terminated)
16+
----
17+
18+
Example of a delayed signal:
19+
20+
[source,swift]
21+
----
22+
let delayedSigaction = try SigactionDelayer_Unsig.registerDelayedSigaction(Signal.terminated, handler: { signal, doneHandler in
23+
logger.debug("Received signal \(signal); delaying it to clean-up")
24+
asyncCleanUp{
25+
logger.debug("Cleanup is done, allowing signal to go through")
26+
doneHandler(true)
27+
})
28+
})
29+
----
30+
31+
When both examples are put in the same code, when the program receives the
32+
terminated signal (15 on macOS), the following should be logged:
33+
34+
[source,text]
35+
----
36+
Received signal SIGTERM; delaying it to clean-up
37+
Cleanup is done, allowing signal to go through
38+
Handling signal SIGTERM from sigaction
39+
----

0 commit comments

Comments
 (0)