Skip to content

Commit 4f3622a

Browse files
authored
cctl: Use AsyncSignalHandler for sigwinch (#105)
We already have a type that does what the setupSigwinchHandler method was doing.
1 parent 0f18608 commit 4f3622a

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

Sources/cctl/RunCommand.swift

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ extension Application {
8484
kernel: kernel,
8585
initPath: .init(filePath: initBlock)
8686
)
87-
let sigwinch = setupSigwinchHandler()
87+
let sigwinchStream = AsyncSignalHandler.create(notify: [SIGWINCH])
8888

8989
let current = try Terminal.current
9090
try current.setraw()
@@ -139,7 +139,7 @@ extension Application {
139139

140140
try await withThrowingTaskGroup(of: Void.self) { group in
141141
group.addTask {
142-
for await _ in sigwinch {
142+
for await _ in sigwinchStream.signals {
143143
try await container.resize(to: try current.size)
144144
}
145145
}
@@ -151,17 +151,6 @@ extension Application {
151151
}
152152
}
153153

154-
private func setupSigwinchHandler() -> AsyncStream<Void> {
155-
let sigwinch = DispatchSource.makeSignalSource(signal: SIGWINCH)
156-
let stream = AsyncStream<Void> { cont in
157-
sigwinch.setEventHandler {
158-
cont.yield()
159-
}
160-
}
161-
sigwinch.resume()
162-
return stream
163-
}
164-
165154
private static let appRoot: URL = {
166155
FileManager.default.urls(
167156
for: .applicationSupportDirectory,

0 commit comments

Comments
 (0)