windows - How to gracefully shutdown a Java application that is terminated as a result of closing the command line from which it was executed? -


there answered question on best way gracefully shutdown java command line program. shutdown hook job in case when program terminated ctrl+c.

my question how gracefully exit if command line closed during execution of java program? tested shutdown hook didn't work in case. cannot find out happens virtual machine in scenario. process , threads killed instantly? kind of signal closing command line produce?

so, how particular problem can solved?

edit: problem concerns windows environment.

logically, sighup (terminal hangup) should raised.

actually, i've checked guess simple shell script. yes, when user closes terminal emulator in application started (and wasn't detached), application receives sighup. set sighup handler , react accordingly. usual behaviour terminate application, intents may different.

also if java application performs stdin/stdout operations, should closed or @ least re-cofigured when hup received, because attempt read/write non existing terminal lead sigpipe and/or program block.

for windows take @ catch windows terminal closing on running process


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -