From 4f3622a4e582809ec3097e3daf238d7f1baadb0f Mon Sep 17 00:00:00 2001 From: Danny Canter Date: Thu, 12 Jun 2025 07:38:34 -0700 Subject: [PATCH] cctl: Use AsyncSignalHandler for sigwinch (#105) We already have a type that does what the setupSigwinchHandler method was doing. --- Sources/cctl/RunCommand.swift | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/Sources/cctl/RunCommand.swift b/Sources/cctl/RunCommand.swift index 823898b3..01a9d256 100644 --- a/Sources/cctl/RunCommand.swift +++ b/Sources/cctl/RunCommand.swift @@ -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 { - let sigwinch = DispatchSource.makeSignalSource(signal: SIGWINCH) - let stream = AsyncStream { cont in - sigwinch.setEventHandler { - cont.yield() - } - } - sigwinch.resume() - return stream - } - private static let appRoot: URL = { FileManager.default.urls( for: .applicationSupportDirectory,