Skip to content

Commit

Permalink
Add support for SIGWINCH (#161)
Browse files Browse the repository at this point in the history
# Motivation
`SIGWINCH` is sent to applications when the window resizes. This is useful to observe for terminal applications to reformat the logging one resize.

# Modification
This PR adds support for `SIGWINCH` in `UnixSignal`s.
  • Loading branch information
FranzBusch authored Oct 10, 2023
1 parent 4d11d98 commit b71a961
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/UnixSignals/UnixSignal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public struct UnixSignal: Hashable, Sendable, CustomStringConvertible {
case sigusr2
case sigalrm
case sigquit
case sigwinch
}

private let wrapped: Wrapped
Expand All @@ -57,6 +58,8 @@ public struct UnixSignal: Hashable, Sendable, CustomStringConvertible {
public static let sigusr1 = Self(.sigusr1)
public static let sigusr2 = Self(.sigusr2)
public static let sigalrm = Self(.sigalrm)
/// Signal when the window is resized.
public static let sigwinch = Self(.sigwinch)
}

extension UnixSignal.Wrapped: Hashable {}
Expand All @@ -79,6 +82,8 @@ extension UnixSignal.Wrapped: CustomStringConvertible {
return "SIGUSR2"
case .sigalrm:
return "SIGALRM"
case .sigwinch:
return "SIGWINCH"
}
}
}
Expand All @@ -100,6 +105,8 @@ extension UnixSignal.Wrapped {
return SIGUSR2
case .sigalrm:
return SIGALRM
case .sigwinch:
return SIGWINCH
}
}
}
1 change: 1 addition & 0 deletions Tests/UnixSignalsTests/UnixSignalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ final class UnixSignalTests: XCTestCase {
assert(.sigusr1, description: "SIGUSR1")
assert(.sigusr2, description: "SIGUSR2")
assert(.sigterm, description: "SIGTERM")
assert(.sigwinch, description: "SIGWINCH")
}

func testCancelledTask() async throws {
Expand Down

0 comments on commit b71a961

Please sign in to comment.