File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
ReleaseTooling/Sources/Utils Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -147,14 +147,24 @@ public extension Shell {
147
147
print ( " ----------------- COMMAND OUTPUT ----------------- " )
148
148
}
149
149
task. launch ( )
150
+ // If we are not outputting to the console, there is a possibility that
151
+ // the output pipe gets filled (e.g. when running a command that generates
152
+ // lots of output). In this scenario, the process will hang and
153
+ // `task.waitUntilExit()` will never return. To work around this issue,
154
+ // calling `outHandle.readDataToEndOfFile()` before `task.waitUntilExit()`
155
+ // will read from the pipe until the process ends.
156
+ var outData : Data !
157
+ if !outputToConsole {
158
+ outData = outHandle. readDataToEndOfFile ( )
159
+ }
160
+
150
161
task. waitUntilExit ( )
151
162
if outputToConsole { print ( " ----------------- END COMMAND OUTPUT ----------------- " ) }
152
163
153
164
let fullOutput : String
154
165
if outputToConsole {
155
166
fullOutput = output. joined ( separator: " \n " )
156
167
} else {
157
- let outData = outHandle. readDataToEndOfFile ( )
158
168
// Force unwrapping since we know it's UTF8 coming from the console.
159
169
fullOutput = String ( data: outData, encoding: . utf8) !
160
170
}
You can’t perform that action at this time.
0 commit comments