My custom security manager currently blocks graceful closing due to SIGTERMs. The follow message is displayed:
Java HotSpot(TM) 64-Bit Server VM warning: Exception java.lang.SecurityException occurred dispatching signal SIGTERM to handler- the VM may need to be forcibly terminated
What should I do to enable shutting down due to SIGTERMS but nothing more?
Your implementation has probably disabled the full debugging information from
-Djava.security.debug=allif you omit to callsuper.checkAccess. If you write first in yourSecurityManagerimplementationand run with
-Djava.security.debug=all, you get information aboutcheckAccesscalls to allow and permissions to add to your policy file. I sum up:As a result, you enable
SIGTERMsignal handling the stricter way with the following code in yourSecurityManager:And also these permissions granting in your
java.security.policyfile:The full information is available here but it is really not obvious to do it right, the try-and-fix method is still the fastest way.