use of sun.misc.SignalHandler in project jdepth by Crab2died.
the class SignalCatch method main.
public static void main(String... args) throws IOException {
SignalHandler handler = new SignalCatch();
handler.handle(new Signal("TERM"));
handler.handle(new Signal("SEGV"));
handler.handle(new Signal("ILL"));
handler.handle(new Signal("FPE"));
handler.handle(new Signal("ABRT"));
handler.handle(new Signal("INT"));
handler.handle(new Signal("BREAK"));
}
use of sun.misc.SignalHandler in project orientdb by orientechnologies.
the class OSignalHandler method listenTo.
public void listenTo(final String name, final SignalHandler iListener) {
Signal signal = new Signal(name);
SignalHandler redefinedHandler = Signal.handle(signal, iListener);
if (redefinedHandler != null) {
redefinedHandlers.put(signal, redefinedHandler);
}
}
use of sun.misc.SignalHandler in project batfish by batfish.
the class Driver method mainRunWorkService.
private static void mainRunWorkService() {
if (_mainSettings.getTracingEnable() && !GlobalTracer.isRegistered()) {
initTracer();
}
String protocol = _mainSettings.getSslDisable() ? "http" : "https";
String baseUrl = String.format("%s://%s", protocol, _mainSettings.getServiceBindHost());
URI baseUri = UriBuilder.fromUri(baseUrl).port(_mainSettings.getServicePort()).build();
_mainLogger.debug(String.format("Starting server at %s\n", baseUri));
ResourceConfig rc = new ResourceConfig(Service.class).register(new JettisonFeature());
if (_mainSettings.getTracingEnable()) {
rc.register(ServerTracingDynamicFeature.class);
}
try {
if (_mainSettings.getSslDisable()) {
GrizzlyHttpServerFactory.createHttpServer(baseUri, rc);
} else {
CommonUtil.startSslServer(rc, baseUri, _mainSettings.getSslKeystoreFile(), _mainSettings.getSslKeystorePassword(), _mainSettings.getSslTrustAllCerts(), _mainSettings.getSslTruststoreFile(), _mainSettings.getSslTruststorePassword(), ConfigurationLocator.class, Driver.class);
}
if (_mainSettings.getCoordinatorRegister()) {
// this function does not return until registration succeeds
registerWithCoordinatorPersistent();
}
if (_mainSettings.getParentPid() > 0) {
if (SystemUtils.IS_OS_WINDOWS) {
_mainLogger.errorf("Parent process monitoring is not supported on Windows. We'll live without it.");
} else {
Executors.newScheduledThreadPool(1).scheduleAtFixedRate(new CheckParentProcessTask(_mainSettings.getParentPid()), 0, PARENT_CHECK_INTERVAL_MS, TimeUnit.MILLISECONDS);
SignalHandler handler = signal -> _mainLogger.infof("BFS: Ignoring signal %s\n", signal);
Signal.handle(new Signal("INT"), handler);
}
}
// sleep indefinitely, check for parent pid and coordinator each time
while (true) {
Thread.sleep(COORDINATOR_CHECK_INTERVAL_MS);
/*
* every time we wake up, we check if the coordinator has polled us recently
* if not, re-register the service. the coordinator might have died and come back.
*/
if (_mainSettings.getCoordinatorRegister() && new Date().getTime() - _lastPollFromCoordinator.getTime() > COORDINATOR_POLL_TIMEOUT_MS) {
// this function does not return until registration succeeds
registerWithCoordinatorPersistent();
}
}
} catch (ProcessingException e) {
String msg = "FATAL ERROR: " + e.getMessage() + "\n";
_mainLogger.error(msg);
System.exit(1);
} catch (Exception ex) {
String stackTrace = ExceptionUtils.getStackTrace(ex);
_mainLogger.error(stackTrace);
System.exit(1);
}
}
use of sun.misc.SignalHandler in project batfish by batfish.
the class Client method runInteractive.
private void runInteractive() {
SignalHandler handler = signal -> _logger.debugf("Client: Ignoring signal: %s\n", signal);
Signal.handle(new Signal("INT"), handler);
try {
while (!_exit) {
try {
String rawLine = _reader.readLine("batfish> ");
if (rawLine == null) {
break;
}
processCommand(rawLine);
} catch (UserInterruptException e) {
continue;
}
}
} catch (EndOfFileException e) {
// ignored
} catch (Throwable t) {
t.printStackTrace();
} finally {
try {
_reader.getHistory().save();
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of sun.misc.SignalHandler in project presto by prestodb.
the class QueryPreprocessor method preprocessQuery.
public static String preprocessQuery(Optional<String> catalog, Optional<String> schema, String query, List<String> preprocessorCommand, Duration timeout) throws QueryPreprocessorException {
Thread clientThread = Thread.currentThread();
SignalHandler oldHandler = Signal.handle(SIGINT, signal -> clientThread.interrupt());
try {
if (REAL_TERMINAL) {
System.out.print(PREPROCESSING_QUERY_MESSAGE);
System.out.flush();
}
return preprocessQueryInternal(catalog, schema, query, preprocessorCommand, timeout);
} finally {
if (REAL_TERMINAL) {
System.out.print("\r" + Strings.repeat(" ", PREPROCESSING_QUERY_MESSAGE.length()) + "\r");
System.out.flush();
}
Signal.handle(SIGINT, oldHandler);
// clear interrupt status
Thread.interrupted();
}
}
Aggregations