Skip to content

Commit

Permalink
IO/PKG: Fix hanging on shell exit by forcing a timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rken committed Jan 22, 2025
1 parent 46104ff commit 090d4db
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.plus
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeoutOrNull

class SharedShell(
tag: String,
Expand All @@ -38,7 +39,7 @@ class SharedShell(
log(aTag) { "Closing!" }
runBlocking {
try {
session.close()
withTimeoutOrNull(5 * 1000) { session.close() } ?: session.cancel()
val exitCode = session.waitFor()
log(aTag) { "FlowCmdShell finished with exitcode $exitCode" }
} catch (e: CancellationException) {
Expand Down

0 comments on commit 090d4db

Please sign in to comment.