Reputation: 27
I found that the runtime shutdown hook in Java can handle SIGTERM, SIGHUP, SIGINT and normal exit(0). However, I only want the hook to handle the SIGTERM signal. How can I limit it? Simple example from geeksforgeeks:
public class ShutDownHook
{
public static void main(String[] args)
{
Runtime.getRuntime().addShutdownHook(new Thread()
{
public void run()
{
System.out.println("Shutdown Hook is running !");
}
});
System.out.println("Application Terminating ...");
}
}
Upvotes: 0
Views: 544
Reputation: 23844
I think what you are looking for is:
Signal.handle(new Signal("TERM"), sig -> {
// handle sigterm
});
Upvotes: 1