From dc4d950bfff455551df57813976084c852c71654 Mon Sep 17 00:00:00 2001 From: Pierrick Greze Date: Thu, 27 Jun 2024 13:50:37 +0900 Subject: [PATCH] Add InputSource.FromParent --- src/main/kotlin/com/github/pgreze/process/InputSource.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/kotlin/com/github/pgreze/process/InputSource.kt b/src/main/kotlin/com/github/pgreze/process/InputSource.kt index 258d686..f97d565 100644 --- a/src/main/kotlin/com/github/pgreze/process/InputSource.kt +++ b/src/main/kotlin/com/github/pgreze/process/InputSource.kt @@ -18,6 +18,12 @@ sealed class InputSource { */ class FromStream(val handler: suspend (OutputStream) -> Unit) : InputSource() + /** + * Natively supported parent provided redirection. + * @see ProcessBuilder.Redirect.INHERIT + */ + object FromParent : InputSource() + @Suppress("BlockingMethodInNonBlockingContext") companion object { @JvmStatic @@ -41,4 +47,5 @@ sealed class InputSource { internal fun InputSource.toNative() = when (this) { is InputSource.FromFile -> ProcessBuilder.Redirect.from(file) is InputSource.FromStream -> ProcessBuilder.Redirect.PIPE + is InputSource.FromParent -> ProcessBuilder.Redirect.INHERIT }