Skip to content

Commit 9832dbe

Browse files
committed
Add the list of signals that are supposed to kill a process
1 parent d0f5acb commit 9832dbe

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

Sources/SignalHandling/CStructsInSwift/Signal.swift

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,32 @@ public struct Signal : RawRepresentable, Hashable, Codable, CaseIterable, Custom
2626
* return 0;
2727
* } */
2828

29+
/**
30+
A hand-crafted list of signals that are supposed to kill the process.
31+
Please verify this list suits your needs before using it…
32+
33+
- Important: As previously mentionned, this list is hand-crafted and might be missing signals or having too many of them. */
34+
public static let killingSignals: Set<Signal> = {
35+
return Set(arrayLiteral:
36+
.terminated, /* Default kill */
37+
.interrupt, /* Ctrl-C */
38+
.quit /* Like .interrupt, but with a Core Dump */
39+
)
40+
}()
41+
2942
/**
3043
A hand-crafted list of signals to forward to subprocesses.
3144
Please verify this list suits your needs before using it…
3245

3346
- Important: As previously mentionned, this list is hand-crafted and does not correspond to any system development notion,
3447
or anything that I know of. */
35-
public static var toForwardToSubprocesses: Set<Signal> {
48+
public static let toForwardToSubprocesses: Set<Signal> = {
3649
return Set(arrayLiteral:
37-
.terminated /* Default kill */,
38-
.interrupt /* Ctrl-C */,
39-
.quit /* Like .interrupt, but with a Core Dump */,
40-
.hangup /* Not sure about that one but might be good: the user’s terminal is disconnected */,
41-
.suspended /* Ctrl-Z */,
50+
.hangup, /* Not sure about that one but might be good: the user’s terminal is disconnected */
51+
.suspended, /* Ctrl-Z */
4252
.continued /* Resume stopped process (from .suspended forwarding for instance) when we are resumed */
43-
)
44-
}
53+
).union(killingSignals)
54+
}()
4555

4656
/* *** Program Error Signals *** */
4757
/* https://www.gnu.org/software/libc/manual/html_node/Program-Error-Signals.html */

0 commit comments

Comments
 (0)