Skip to content

Commit 7b773c7

Browse files
johnbuteJohn Bute
and
John Bute
authored
Foreground process fix (#226)
Fixed bug where child process did not set parent process back to foreground --------- Co-authored-by: John Bute <[email protected]>
1 parent 76ef042 commit 7b773c7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Sources/Swiftly/Init.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ internal struct Init: SwiftlyCommand {
7676
These locations can be changed with SWIFTLY_HOME and SWIFTLY_BIN environment variables and run this again.
7777
\(installMsg)
7878
""")
79+
7980
guard SwiftlyCore.promptForConfirmation(defaultBehavior: true) else {
8081
throw SwiftlyError(message: "Swiftly installation has been cancelled")
8182
}

Sources/SwiftlyCore/Platform.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ extension Platform {
209209
if pgid != -1 {
210210
tcsetpgrp(STDOUT_FILENO, process.processIdentifier)
211211
}
212+
213+
defer { if pgid != -1 {
214+
tcsetpgrp(STDOUT_FILENO, pgid)
215+
}}
216+
212217
process.waitUntilExit()
213218

214219
guard process.terminationStatus == 0 else {
@@ -250,6 +255,10 @@ extension Platform {
250255
if pgid != -1 {
251256
tcsetpgrp(STDOUT_FILENO, process.processIdentifier)
252257
}
258+
defer { if pgid != -1 {
259+
tcsetpgrp(STDOUT_FILENO, pgid)
260+
}}
261+
253262
let outData = try outPipe.fileHandleForReading.readToEnd()
254263

255264
process.waitUntilExit()

0 commit comments

Comments
 (0)