summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-21 05:02:52 +0000
committerPaul Phillips <paulp@improving.org>2011-01-21 05:02:52 +0000
commitd8dfb6ec6334bfbf4f78fd97b8af2de8441cf7db (patch)
tree5d7958d8ea60cc5c7d574a019678ce36cf528902 /src/library
parente20693030316e4854886f7a945e6a6a3117ca071 (diff)
downloadscala-d8dfb6ec6334bfbf4f78fd97b8af2de8441cf7db.tar.gz
scala-d8dfb6ec6334bfbf4f78fd97b8af2de8441cf7db.tar.bz2
scala-d8dfb6ec6334bfbf4f78fd97b8af2de8441cf7db.zip
A little debugging infrastructure for sys.process.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/sys/process/package.scala63
1 files changed, 43 insertions, 20 deletions
diff --git a/src/library/scala/sys/process/package.scala b/src/library/scala/sys/process/package.scala
index 0185b1a8f0..9421bff88d 100644
--- a/src/library/scala/sys/process/package.scala
+++ b/src/library/scala/sys/process/package.scala
@@ -6,29 +6,52 @@
** |/ **
\* */
-package scala.sys
+// Developer note:
+// scala -J-Dscala.process.debug
+// for process debugging output.
+//
+package scala.sys {
+ package object process extends ProcessImplicits {
+ def javaVmArguments: List[String] = {
+ import collection.JavaConversions._
-package object process extends ProcessImplicits {
- // These are in a nested object instead of at the package level
- // due to the issues described in tickets #3160 and #3836.
- private[process] object processInternal {
- type =?>[-A, +B] = PartialFunction[A, B]
- type Closeable = java.io.Closeable
- type File = java.io.File
- type IOException = java.io.IOException
- type InputStream = java.io.InputStream
- type JProcess = java.lang.Process
- type JProcessBuilder = java.lang.ProcessBuilder
- type OutputStream = java.io.OutputStream
- type SyncVar[T] = scala.concurrent.SyncVar[T]
- type URL = java.net.URL
-
- def onInterrupt[T](handler: => T): Throwable =?> T = {
- case _: InterruptedException => handler
+ java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().toList
}
+ }
+ // private val shell: String => Array[String] =
+ // if (isWin) Array("cmd.exe", "/C", _)
+ // else Array("sh", "-c", _)
+
+ package process {
+ // These are in a nested object instead of at the package level
+ // due to the issues described in tickets #3160 and #3836.
+ private[process] object processInternal {
+ final val processDebug = props contains "scala.process.debug"
+ // final val processDebug = true
+ dbg("Initializing process package.")
+
+ type =?>[-A, +B] = PartialFunction[A, B]
+ type Closeable = java.io.Closeable
+ type File = java.io.File
+ type IOException = java.io.IOException
+ type InputStream = java.io.InputStream
+ type JProcess = java.lang.Process
+ type JProcessBuilder = java.lang.ProcessBuilder
+ type OutputStream = java.io.OutputStream
+ type SyncVar[T] = scala.concurrent.SyncVar[T]
+ type URL = java.net.URL
+
+ def onInterrupt[T](handler: => T): Throwable =?> T = {
+ case _: InterruptedException => handler
+ }
+
+ def ioFailure[T](handler: IOException => T): Throwable =?> T = {
+ case e: IOException => handler(e)
+ }
- def ioFailure[T](handler: IOException => T): Throwable =?> T = {
- case e: IOException => handler(e)
+ def dbg(msgs: Any*) = if (processDebug) {
+ Console.println("[process] " + (msgs mkString " "))
+ }
}
}
}