mirror of https://github.com/sbt/sbt.git
Merge remote-tracking branch 'remotesbt/0.13' into 0.13
This commit is contained in:
commit
150236900a
2
LICENSE
2
LICENSE
|
|
@ -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
4
NOTICE
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue