summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-10-31 08:08:55 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-10-31 08:08:55 -0700
commit1f9124b74566efe82e1c4f8d33fcd8618ea0f599 (patch)
tree079df2da67f96bf4839a65d2d6f3e431f5fd6dfa
parentd3f2d6da5da059a7d7566a073a55264ae933b857 (diff)
parentc7c79c83b5a7560df60ba9b4578bbce02514a22a (diff)
downloadscala-1f9124b74566efe82e1c4f8d33fcd8618ea0f599.tar.gz
scala-1f9124b74566efe82e1c4f8d33fcd8618ea0f599.tar.bz2
scala-1f9124b74566efe82e1c4f8d33fcd8618ea0f599.zip
Merge pull request #1522 from possiblywrong/2.10.x
SI-6488: Fix for race with open I/O fds
-rw-r--r--src/library/scala/sys/process/ProcessImpl.scala5
-rw-r--r--test/files/run/t6488.check1
-rw-r--r--test/files/run/t6488.scala11
3 files changed, 16 insertions, 1 deletions
diff --git a/src/library/scala/sys/process/ProcessImpl.scala b/src/library/scala/sys/process/ProcessImpl.scala
index cdf7d72caa..84ef5f277b 100644
--- a/src/library/scala/sys/process/ProcessImpl.scala
+++ b/src/library/scala/sys/process/ProcessImpl.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()
}
}
diff --git a/test/files/run/t6488.check b/test/files/run/t6488.check
new file mode 100644
index 0000000000..35821117c8
--- /dev/null
+++ b/test/files/run/t6488.check
@@ -0,0 +1 @@
+Success
diff --git a/test/files/run/t6488.scala b/test/files/run/t6488.scala
new file mode 100644
index 0000000000..487614ecfd
--- /dev/null
+++ b/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")
+ }
+}