private Object createSignalHandler(final Map<String, Object> jvmSignalHandlers) {
        InvocationHandler invocationHandler = new InvocationHandler() {

            private String getName(Object signal) throws Throwable {
                try {
                    return (String) signalGetNameMethod.invoke(signal);
                } catch (InvocationTargetException e) {
                    throw e.getCause();
                }
            }

            private void handle(Object signalHandler, Object signal) throws ReflectiveOperationException {
                signalHandlerHandleMethod.invoke(signalHandler, signal);
            }

            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                Object signal = args[0];
                log.info("Terminating process due to signal {}", signal);
                Object handler = jvmSignalHandlers.get(getName(signal));
                if (handler != null)
                    handle(handler, signal);
                return null;
            }
        };
        return Proxy.newProxyInstance(Utils.getContextOrKafkaClassLoader(), new Class[] {signalHandlerClass},
                invocationHandler);
    }
Register signal handler to log termination due to SIGTERM, SIGHUP and SIGINT (control-c). This method
does not currently work on Windows.

@implNote sun.misc.Signal and sun.misc.SignalHandler are described as "not encapsulated" in
http://openjdk.java.net/jeps/260. However, they are not available in the compile classpath if the `--release`
flag is used. As a workaround, we rely on reflection.
clients/src/main/java/org/apache/kafka/common/utils/LoggingSignalHandler.java