mirror of
https://github.com/apple/container.git
synced 2026-09-12 02:35:42 +00:00
cctl: Use AsyncSignalHandler for sigwinch (#105)
We already have a type that does what the setupSigwinchHandler method was doing.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user