Skip to content

Foreground process fix #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 13, 2025
Merged
1 change: 1 addition & 0 deletions Sources/Swiftly/Init.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ internal struct Init: SwiftlyCommand {
These locations can be changed with SWIFTLY_HOME and SWIFTLY_BIN environment variables and run this again.
\(installMsg)
""")

guard SwiftlyCore.promptForConfirmation(defaultBehavior: true) else {
throw SwiftlyError(message: "Swiftly installation has been cancelled")
}
Expand Down
9 changes: 9 additions & 0 deletions Sources/SwiftlyCore/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ extension Platform {
if pgid != -1 {
tcsetpgrp(STDOUT_FILENO, process.processIdentifier)
}

defer { if pgid != -1 {
tcsetpgrp(STDOUT_FILENO, pgid)
}}

process.waitUntilExit()

guard process.terminationStatus == 0 else {
Expand Down Expand Up @@ -250,6 +255,10 @@ extension Platform {
if pgid != -1 {
tcsetpgrp(STDOUT_FILENO, process.processIdentifier)
}
defer { if pgid != -1 {
tcsetpgrp(STDOUT_FILENO, pgid)
}}

let outData = try outPipe.fileHandleForReading.readToEnd()

process.waitUntilExit()
Expand Down