Skip to content

Commit 4b5165a

Browse files
John ButeJohn Bute
authored andcommitted
improved locality of defer
1 parent 5c2c0d4 commit 4b5165a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Sources/SwiftlyCore/Platform.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,13 @@ extension Platform {
209209
if pgid != -1 {
210210
tcsetpgrp(STDOUT_FILENO, process.processIdentifier)
211211
}
212-
process.waitUntilExit()
213212

214213
defer { if pgid != -1 {
215214
tcsetpgrp(STDOUT_FILENO, pgid)
216215
}}
217216

217+
process.waitUntilExit()
218+
218219
guard process.terminationStatus == 0 else {
219220
throw RunProgramError(exitCode: process.terminationStatus, program: args.first!)
220221
}
@@ -254,14 +255,14 @@ extension Platform {
254255
if pgid != -1 {
255256
tcsetpgrp(STDOUT_FILENO, process.processIdentifier)
256257
}
257-
let outData = try outPipe.fileHandleForReading.readToEnd()
258-
259-
process.waitUntilExit()
260-
261258
defer { if pgid != -1 {
262259
tcsetpgrp(STDOUT_FILENO, pgid)
263260
}}
264261

262+
let outData = try outPipe.fileHandleForReading.readToEnd()
263+
264+
process.waitUntilExit()
265+
265266
guard process.terminationStatus == 0 else {
266267
throw RunProgramError(exitCode: process.terminationStatus, program: args.first!)
267268
}

0 commit comments

Comments
 (0)