Open jredfox opened 3 years ago
update I am now in the process of fixing this for both windows and non windows alike. any signal at all that isn't ignored by default will A: get handled if it's not handled and will call anything appropriate methods term or exit depending on the signal. B: it will always call System.exit(0) or System.exit(-1) depending on the signal so the hooks can fire. It should also dethatch itself the JVM from the CLI as described in stackoverflow.
Update: ADDED WINDOWS 10 SHUTDOWN HOOKS! Note: CONTROL_CLOSE_EVENT is essentially a terminate and I don't have a work around for this yet. but at least your app has 5 seconds to shutdown as of right now instead of nothing
Update 2: Replacement of the X button for conHost.exe
. I replaced the x button which people said couldn't be done the logic for it isn't finished yet. It also appears that adding support for handling task managers close messages is possible both on CLI and non CLI double clicks(invisible windows to receive task manager msgs). I will continue to work on finishing the replacement and PIDIA for windows. I don't have macOs or linux done but it will be alot easier then windows that's for sure
Features:
Windows handle CTRL+CLOSE & SIGTERM also SIGINT and SIGBREAK. the process should be the same for other os's due to JNI: https://docs.microsoft.com/en-us/windows/console/ctrl-close-signal?redirectedfrom=MSDN https://stackoverflow.com/a/9277766/8477015 https://stackoverflow.com/questions/2541597/how-to-gracefully-handle-the-sigkill-signal-in-java https://docs.microsoft.com/en-us/windows/console/ctrl-c-and-ctrl-break-signals https://stackoverflow.com/questions/9277630/windows-shutdown-hook-on-java-application-run-from-a-bat-script
POSIX: register signal handles for all signals that should stop or terminate the program. based on the value determines the exit code. if it's a normal code from an x button it should exit on 0 and call shutdown instead of term. if it's not a normal code then exit -1 and call terminate method instead of shutdown. terminate may have a timeout of 2-5s or less depending upon the code. normal is like
SIGINT
and maybe others and abnormal isSIGTERM
and non handleables isSIGKILL