Cygwin CTRL-C (Signal Interrupts) not working properly - JVM Shutdown Hooks not starting

ⅰ亾dé卋堺 提交于 2019-12-04 22:56:37

Bash invokes non-cygwin (windows) executables through an intermediate bash process (bash shell -> bash -> java). When you type Ctrl-C, the bash process gets a SIGINT and kills the child java process, so the shutdown hooks are not invoked. Windows processes are not aware of signals like SIGINT, SIGTERM or SIGKILL.

As described in the -Xrs option documentation, the java process registers a console control handler for the CTRL_C_EVENT windows event and that triggers a graceful termination that invokes the shutdown hooks. To get Ctrl-C to work as expected, you'd need to make sure the java process receives it, but right now that's intercepted by bash and not passed forward to the child process.

This issue can be restated as: How can I have Cygwin pass Ctrl-C forward to windows console processes?

Note: The bash behavior described above was verified on version 1.7.25.

This thread perhaps shed some light. Some options

timeout 1d <command>

or

Ctrl-C patch by Howard Chu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!