Skip to content

Commit 36f71f6

Browse files
authored
Add support for SIGQUIT (#146)
# Motivation Some applications want to react to `SIGQUIT` which is similar to `SIGINT` but normally maps to a different key `C-\`. # Modification This PR adds support for `SIGQUIT` in the `UnixSignal`s module. # Result Support for `SIGQUIT`.
1 parent de1ef4b commit 36f71f6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Sources/UnixSignals/UnixSignal.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public struct UnixSignal: Hashable, Sendable, CustomStringConvertible {
3030
case sigusr1
3131
case sigusr2
3232
case sigalrm
33+
case sigquit
3334
}
3435

3536
private let wrapped: Wrapped
@@ -49,6 +50,8 @@ public struct UnixSignal: Hashable, Sendable, CustomStringConvertible {
4950
public static let sighup = Self(.sighup)
5051
/// Issued if the user sends an interrupt signal.
5152
public static let sigint = Self(.sigint)
53+
/// Issued if the user sends a quit signal.
54+
public static let sigquit = Self(.sigquit)
5255
/// Software termination signal.
5356
public static let sigterm = Self(.sigterm)
5457
public static let sigusr1 = Self(.sigusr1)
@@ -66,6 +69,8 @@ extension UnixSignal.Wrapped: CustomStringConvertible {
6669
return "SIGHUP"
6770
case .sigint:
6871
return "SIGINT"
72+
case .sigquit:
73+
return "SIGQUIT"
6974
case .sigterm:
7075
return "SIGTERM"
7176
case .sigusr1:
@@ -85,6 +90,8 @@ extension UnixSignal.Wrapped {
8590
return SIGHUP
8691
case .sigint:
8792
return SIGINT
93+
case .sigquit:
94+
return SIGQUIT
8895
case .sigterm:
8996
return SIGTERM
9097
case .sigusr1:

Tests/UnixSignalsTests/UnixSignalTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ final class UnixSignalTests: XCTestCase {
114114

115115
assert(.sigalrm, rawValue: SIGALRM)
116116
assert(.sigint, rawValue: SIGINT)
117+
assert(.sigquit, rawValue: SIGQUIT)
117118
assert(.sighup, rawValue: SIGHUP)
118119
assert(.sigusr1, rawValue: SIGUSR1)
119120
assert(.sigusr2, rawValue: SIGUSR2)
@@ -127,6 +128,7 @@ final class UnixSignalTests: XCTestCase {
127128

128129
assert(.sigalrm, description: "SIGALRM")
129130
assert(.sigint, description: "SIGINT")
131+
assert(.sigquit, description: "SIGQUIT")
130132
assert(.sighup, description: "SIGHUP")
131133
assert(.sigusr1, description: "SIGUSR1")
132134
assert(.sigusr2, description: "SIGUSR2")

0 commit comments

Comments
 (0)