cctl: Use AsyncSignalHandler for sigwinch (#105)

We already have a type that does what the setupSigwinchHandler method
was doing.
This commit is contained in:
Danny Canter
2025-06-12 10:38:34 -04:00
committed by GitHub
parent 0f18608f0e
commit 4f3622a4e5
+2 -13
View File
@@ -84,7 +84,7 @@ extension Application {
kernel: kernel,
initPath: .init(filePath: initBlock)
)
let sigwinch = setupSigwinchHandler()
let sigwinchStream = AsyncSignalHandler.create(notify: [SIGWINCH])
let current = try Terminal.current
try current.setraw()
@@ -139,7 +139,7 @@ extension Application {
try await withThrowingTaskGroup(of: Void.self) { group in
group.addTask {
for await _ in sigwinch {
for await _ in sigwinchStream.signals {
try await container.resize(to: try current.size)
}
}
@@ -151,17 +151,6 @@ extension Application {
}
}
private func setupSigwinchHandler() -> AsyncStream<Void> {
let sigwinch = DispatchSource.makeSignalSource(signal: SIGWINCH)
let stream = AsyncStream<Void> { cont in
sigwinch.setEventHandler {
cont.yield()
}
}
sigwinch.resume()
return stream
}
private static let appRoot: URL = {
FileManager.default.urls(
for: .applicationSupportDirectory,