I have a shutdown hook in my application (created using Runtime.getRuntime().addShutdownHook
). However if I launch the application from within Eclipse, when it is shut-down the shutdown hook doesn't execute.
I think this is because Eclipse sends the equivalent of a force-kill signal to the process, which doesn't cause the shut-down hook to execute (equivalent of taskkill /F on Windows or kill -p on Linux), though I'm not absolutely sure.
Does anyone know how to get around this? I'm running Windows (Vista), and I've a feeling it may be a Windows-specific issue, but I'm not sure.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…