Skip to content

Commit

Permalink
SI-6488: Stop I/O threads prior to Process destruction
Browse files Browse the repository at this point in the history
  • Loading branch information
Declan Conlon committed Oct 26, 2012
1 parent 34d021a commit c7c79c8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/library/scala/sys/process/ProcessImpl.scala
Expand Up @@ -222,7 +222,10 @@ private[process] trait ProcessImpl {
p.exitValue()
}
override def destroy() = {
try p.destroy()
try{
outputThreads foreach (_.stop())
p.destroy()
}
finally inputThread.interrupt()
}
}
Expand Down
1 change: 1 addition & 0 deletions test/files/run/t6488.check
@@ -0,0 +1 @@
Success
11 changes: 11 additions & 0 deletions test/files/run/t6488.scala
@@ -0,0 +1,11 @@
import sys.process._
object Test {
// Program that prints "Success" if the command was successfully run then destroyed
// It will silently pass if the command "/bin/ls" does not exist
// It will fail due to the uncatchable exception in t6488 race condition
def main(args: Array[String]) {
try Process("/bin/ls").run(ProcessLogger { _ => () }).destroy
catch { case _ => () }
println("Success")
}
}

0 comments on commit c7c79c8

Please sign in to comment.