Skip to content

Commit

Permalink
Fix destroyForcibly PR formatting (#10)
Browse files Browse the repository at this point in the history
* Destroy forcibly on demand

* Normalize args comments
  • Loading branch information
pgreze authored Aug 13, 2021
1 parent dfd1cc4 commit 0afdb42
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/kotlin/com/github/pgreze/process/Process.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ suspend fun process(
env: Map<String, String>? = null,
/** Override the process working directory. */
directory: File? = null,
/** Consume without delay all streams configured with [Redirect.CAPTURE] */
/** Determine if process should be destroyed forcibly on job cancellation. */
destroyForcibly: Boolean = false,
/** Consume without delay all streams configured with [Redirect.CAPTURE]. */
consumer: suspend (String) -> Unit = {},
): ProcessResult = coroutineScopeIO {
// Based on the fact that it's hardcore to achieve manually:
Expand Down Expand Up @@ -95,7 +97,10 @@ suspend fun process(
resultCode = runInterruptible { process.waitFor() },
)
} catch (e: CancellationException) {
process.destroy()
when (destroyForcibly) {
true -> process.destroyForcibly()
false -> process.destroy()
}
throw e
}
}
Expand Down

0 comments on commit 0afdb42

Please sign in to comment.