Sending SIGINT (Ctrl-C) to program running in Eclipse Console

自古美人都是妖i 提交于 2019-12-20 17:43:14

问题


I have setup a run configuration in Eclipse and need to send SIGINT (Ctrl+C) to the program. There is cleanup code in the program that runs after SIGINT, so pressing Eclipse's "Terminate" buttons won't work (they send SIGKILL I think). Typing CTRL+C into the Console also doesn't work.

How do I send SIGINT to a process running inside an Eclipse Console?

(FWIW I am running a Twisted daemon and need Twisted to shutdown correctly, which only occurs on SIGINT)


回答1:


If you can determine the process with a utility such as ps, you can use kill to send it a SIGINT. The program will likely be a child process of eclipse.

kill -s INT <pid>



回答2:


You can send the command via one line:

 kill -SIGINT $(ps aux | grep ProgrammName | grep -v grep | awk '{print $2}') 

Get the process id and than send the sigint signal




回答3:


That still seems to be an open issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=38016

Just for the sake of completeness: If you came here to find a way to terminate a read line from System.in, Ctrl + Z worked for me (on Windows).



来源:https://stackoverflow.com/questions/8814383/sending-sigint-ctrl-c-to-program-running-in-eclipse-console

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