Skip to content

Commit

Permalink
Guard against a runaway thread exception when processing input in Os.…
Browse files Browse the repository at this point in the history
…proc.
  • Loading branch information
robby-phd committed Oct 22, 2024
1 parent 7816ea2 commit e77ab94
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion library/jvm/src/main/scala/org/sireum/Os_Ext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,21 @@ object Os_Ext {
val pOut = new ProcessOutput(po.fOut)
def pErr = if (p.isErrAsOut) pOut else new ProcessOutput(po.fErr)
val stdin: _root_.os.ProcessInput = p.in match {
case Some(s) => s.value
case Some(s) => new os.ProcessInput {
val r: os.Source = s.value
def redirectFrom: ProcessBuilder.Redirect = ProcessBuilder.Redirect.PIPE
def processInput(stdin: => SubProcess.InputStream): scala.Option[Runnable] = scala.Some(() => {
try {
r.writeBytesTo(stdin)
} catch {
case _: Throwable =>
} finally {
try stdin.close() catch {
case _: Throwable =>
}
}
})
}
case _ => _root_.os.Inherit
}
val sp = _root_.os.proc(p.cmds.elements.map(_.value: _root_.os.Shellable)).
Expand Down

0 comments on commit e77ab94

Please sign in to comment.