Skip to content

Commit 68b59f3

Browse files
Allow to ignore SIGINT (#53)
1 parent f3f21ee commit 68b59f3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

frontend/src/main/scala/bloop/Bloop.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import java.io.File
3232
import org.slf4j
3333
import java.nio.file.attribute.PosixFilePermissions
3434
import java.nio.file.Path
35+
import sun.misc.{Signal, SignalHandler}
3536

3637
sealed abstract class Bloop
3738

@@ -67,6 +68,9 @@ object Bloop {
6768
)
6869
}
6970

71+
if (java.lang.Boolean.getBoolean("bloop.ignore-sig-int"))
72+
ignoreSigint()
73+
7074
lockFilesOrHostPort match {
7175
case Left(hostPort) =>
7276
startServer(Left(hostPort))
@@ -80,6 +84,16 @@ object Bloop {
8084
}
8185
}
8286

87+
private def ignoreSigint(): Unit = {
88+
Signal.handle(
89+
new Signal("INT"),
90+
signal => {
91+
System.err.println("Ignoring Ctrl+C interruption")
92+
}
93+
)
94+
()
95+
}
96+
8397
def startServer(socketPathsOrHostPort: Either[(InetAddress, Int), SocketPaths]): Unit = {
8498
val socketAndPathOrHostPort = socketPathsOrHostPort.map { socketPaths =>
8599
val socket = libdaemonjvm.Util.serverSocketFromChannel(

0 commit comments

Comments
 (0)