Skip to content

Commit

Permalink
Foreground process fix (#226)
Browse files Browse the repository at this point in the history
Fixed bug where child process did not set parent process back to foreground

---------

Co-authored-by: John Bute <[email protected]>
  • Loading branch information
johnbute and John Bute authored Feb 13, 2025
1 parent 76ef042 commit 7b773c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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

0 comments on commit 7b773c7

Please sign in to comment.