Merge remote-tracking branch 'remotesbt/0.13' into 0.13

This commit is contained in:
Matej Urbas 2014-04-18 13:48:19 +01:00
commit 150236900a
3 changed files with 35 additions and 3 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2008, 2009, 2010 Steven Blundy, Josh Cough, Mark Harrah, Stuart Roebuck, Tony Sloane, Vesa Vilhonen, Jason Zaugg Copyright (c) 2008-2014 Typesafe Inc, Mark Harrah, Grzegorz Kossakowski, Josh Suereth, Indrajit Raychaudhuri, Eugene Yokota, and other contributors.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

4
NOTICE
View File

@ -1,5 +1,5 @@
Simple Build Tool sbt
Copyright 2008, 2009, 2010 Mark Harrah, Jason Zaugg Copyright (c) 2008-2014 Typesafe Inc, Mark Harrah, Grzegorz Kossakowski, Josh Suereth, Indrajit Raychaudhuri, Eugene Yokota, and other contributors.
Licensed under BSD-style license (see LICENSE) Licensed under BSD-style license (see LICENSE)
Portions based on code from the Scala compiler. Portions of the Scala Portions based on code from the Scala compiler. Portions of the Scala

View File

@ -19,6 +19,38 @@ object Signals
case Right(v) => v case Right(v) => v
} }
} }
/** Helper interface so we can expose internals of signal-isms to others. */
sealed trait Registration {
def remove(): Unit
}
/** Register a signal handler that can be removed later.
* NOTE: Does not stack with other signal handlers!!!!
*/
def register(handler: () => Unit, signal: String = INT): Registration =
// TODO - Maybe we can just ignore things if not is-supported.
if(supported(signal)) {
import sun.misc.{Signal,SignalHandler}
val intSignal = new Signal(signal)
val newHandler = new SignalHandler {
def handle(sig: Signal) { handler() }
}
val oldHandler = Signal.handle(intSignal, newHandler)
object unregisterNewHandler extends Registration {
override def remove(): Unit = {
Signal.handle(intSignal, oldHandler)
}
}
unregisterNewHandler
} else {
// TODO - Maybe we should just throw an exception if we don't support signals...
object NullUnregisterNewHandler extends Registration {
override def remove(): Unit = ()
}
NullUnregisterNewHandler
}
def supported(signal: String): Boolean = def supported(signal: String): Boolean =
try try
{ {