Permalink
Browse files

SI-6488: Stop I/O threads prior to Process destruction

  • Loading branch information...
1 parent 34d021a commit c7c79c83b5a7560df60ba9b4578bbce02514a22a Declan Conlon committed Oct 10, 2012
Showing with 16 additions and 1 deletion.
  1. +4 −1 src/library/scala/sys/process/ProcessImpl.scala
  2. +1 −0 test/files/run/t6488.check
  3. +11 −0 test/files/run/t6488.scala
@@ -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()
}
}
@@ -0,0 +1 @@
+Success
@@ -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.