CLI: Defer tty reset immediately (#488)

We were defer closing the IO for run/exec/start fairly late in the
container run cycle which had the downside of that if the container run
failed your tty would be stuck in raw mode. This change just moves the
closing (return tty to origin state) to directly after we create the IO.
This commit is contained in:
Danny Canter
2025-08-13 15:04:18 -04:00
committed by GitHub
parent 3d0c1fee97
commit 66426acfbb
5 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -240,8 +240,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax.git",
"state" : {
"revision" : "fd6373fad9cf3b3bc4e3c06d92f0cfd60007fa8e",
"version" : "602.0.0-prerelease-2025-06-26"
"revision" : "21b3b45635decd1a0b89968f81b6d9a93128f773",
"version" : "602.0.0-prerelease-2025-08-11"
}
},
{
-3
View File
@@ -190,9 +190,6 @@ struct Application: AsyncParsableCommand {
}
try await process.start()
defer {
try? io.close()
}
try io.closeAfterStart()
if let current = io.console {
@@ -70,6 +70,9 @@ extension Application {
do {
let io = try ProcessIO.create(tty: tty, interactive: stdin, detach: false)
defer {
try? io.close()
}
if !self.processFlags.tty {
var handler = SignalThreshold(threshold: 3, signals: [SIGINT, SIGTERM])
+3 -3
View File
@@ -58,15 +58,15 @@ extension Application {
interactive: self.interactive,
detach: detach
)
defer {
try? io.close()
}
let process = try await container.bootstrap(stdio: io.stdio)
progress.finish()
if detach {
try await process.start()
defer {
try? io.close()
}
try io.closeAfterStart()
print(self.containerID)
return
+3 -3
View File
@@ -116,6 +116,9 @@ extension Application {
interactive: self.processFlags.interactive,
detach: detach
)
defer {
try? io.close()
}
let process = try await container.bootstrap(stdio: io.stdio)
progress.finish()
@@ -138,9 +141,6 @@ extension Application {
if detach {
try await process.start()
defer {
try? io.close()
}
try io.closeAfterStart()
print(id)
return