Skip to content

Commit

Permalink
Allow to read from stdin when using run command (#2384)
Browse files Browse the repository at this point in the history
* Use java.lang.ProcessBuilder to run compiled executable in sbt
  • Loading branch information
WojciechMazur committed Sep 27, 2021
1 parent ff8612f commit 48962cd
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -141,9 +141,17 @@ object ScalaNativePluginInternal {
val args = spaceDelimited("<arg>").parsed

logger.running(binary +: args)
val exitCode = Process(binary +: args, None, env: _*)
.run(connectInput = false)
.exitValue

val exitCode = {
// It seems that previously used Scala Process has some bug leading
// to possible ignoring of inherited IO and termination of wrapper
// thread with an exception. We use java.lang ProcessBuilder instead
val proc = new ProcessBuilder()
.command((Seq(binary) ++ args): _*)
.inheritIO()
env.foreach((proc.environment().put(_, _)).tupled)
proc.start().waitFor()
}

val message =
if (exitCode == 0) None
Expand Down

0 comments on commit 48962cd

Please sign in to comment.