Is it possible for Eclipse to terminate gently instead of using SIGKILL? - eclipse

I'm using Eclipse on Windows, with the PyDev plugin for Python development. When I use 'Run' to start my application, it spawns a new Python (CPython) instance. When I use the 'terminate' button (red square), it kills the process. However, it appears to do a SIGKILL, so my shutdown handler is unable to clean up.
Is there any way to get Eclipse to send a SIGTERM, or simulate a keyboard interrupt (ctrl-c) from the Eclipse console?
Note: I'm aware there are other Python IDEs like Komodo or Wing that might solve this problem, but I'm not looking to switch over this.

Eclipse uses the Java Process API which sends the signal. This is a native API and there is no way to change that. I assume that you've tried to install a handler for SIGKILL, too, and that didn't work.
Therefore, the only solution would be to write a small batch file which lists the processes and sends SIGTERM to one of them. Invoke that from a command prompt. If you use Alt-Tab to switch to it, it's almost as comfortable as doing it from inside Eclipse.
Or write a plugin to invoke batch files.

I looked at How can a Java program get its own process ID? and came up with this.
System.out.println("kill -SIGINT "+ProcessHandle.current().pid());
I realize this isn't ideal if you don't want it printing this out for production but if you're just prototyping it's handy. Or you could put it inside an if that only runs if you're debugging.

Related

vscode.dev. Can I write to the console in some way?

Is it possible to write to a console on vscode.dev like with Console.WriteLine("Hello World!");
I'm trying to make some beginner C# tuts, and would like to skip the install IDE part in the beginning, and focus on the language for now.
I'm sorry, can't seem to find any info about this, other than:
"Run and Debug are not available in the web editor. To run and debug, you will need to continue in an environment that can run code, like a codespace or local VS Code."
I was hoping for a simple runtime like here learn.microsoft.com
No, it's not possible. As your cited text clearly states, vscode.dev cannot execute code.

Does Eclipse send a termination signal when a Node.js program is stopped from the console?

I am using Eclipse for Node.js development, along with the Nodeclipse Plugin. I am curious to know, that for a node.js program which is launched via Eclipse, how does Eclipse stop the process, when the stop icon in the console is pressed?
My node.js program has signal handlers for SIGINT and SIGTERM- however, they are not invoked when the process is terminated from Eclipse.
Does Eclipse even send one of these signals? If it does not, how does Eclipse terminate the process? Is there a way to influence this?
Eclipse kills external programs when you click the red button in the console view. More specifically it uses Process.destroy() method.
See this bug for some explanation.
Even though this method could in theory terminate the process gracefully, in practice this causes SIGKILL to be sent under UNIX.
Nodeclipse does not have any special logic for that, that is Eclipse termination.
It is said that process is killed. I don't know how exactly that is implemented on different OSes. To find out ask on Eclipse forum or get Eclipse for Commiters and try to debug.

Stop Eclipse Command Line Pop Ups

I am writing a small FLTK (GUI) program on windows 7 using Eclipse Kepler. My "int main()" function is not even set to receive any command line arguments, yet every time I build the program exe and run it a command line pops up being the GUI interface.
Does anyone know how to suppress this? I do not need a console display for any input or output etc. as this is all controlled via the GUI interface.
Thanks.
It has nothing to see with eclipse. It's a standard behaviour of c++ applications on Windows. Look for console on this page. You will find how to disable it.

Stuck in a loop using Eclipse/Java

I'm trying to figure out while loops and in the process of testing and running the program, the input window is stuck asking me the same question. I can restart the program but there has to be another way. I've searched the site and there are some similar links but not exact. Please, with simplicity, provide me with some sort of an escape command so this window will close without me restarting Eclipse.
There should be a Terminate button in the Console tab when you run the application through Eclipse.
Clicking that will terminate the running process without exiting Eclipse.

Whats the shortcut to Debug in PyDev using Eclipse

The shortcut key is F11 to start debugging. But issue is that I have to be on that file and then hit F11 to start debugging.
Eg.
my file to launch the application is "launch.py" and "example.py".
example.py is open in the editor whereas launch.py is not.
Now, if I hit F11 it will try to launch the application using "example.py" and terminates due to error (as expected).
So then I have to open the "launch.py" in the editor and then hit F11 to start debugging the application.
Is there any neater way to configure the debugging, so that it starts the application in single hit/key?
Edit: example.py is some other file (some module). It does not launch the application.
As this PyDev Eclipse Tutorial suggests:
After the first run, if you type Ctrl+F11, the last file ran is re-run. Or, if you type just F11, a debug session is started with your last run. Let's test this...
Note: This behavior changed in Eclipse 3.3 -- but it's generally recommended to restore it in the preferences at: window > preferences > Run/Debug > Launching and set the Launch Operation to Always launch the previously launched application.
This tutorial will always consider this as the default option.
So, did you have this option selected?
If you have launch at least once launch.py, then you can re-launch it easily.
Although this isn't strictly an answer to what was asked initially, it might help someone looking here that had the same problem as me...
I'm a Java developer mainly, so have the Java view open almost all the time. However, sometimes I want to run some python file to test something (or just create a quick python script, and run it)...
In the Java editor, if the current class has a main(String[] args) method, I run it with (and popup the dialog to ask me what exactly I'd like to run in the middle)
alt+shift+x, j
Unfortunately, that doesn't work in the Python view, and I've not found a similar solution - it just asks me if I'd like to run it as a Java app... however, as the VonC says, you can run the last run thing (provided you've set the preferences accordingly) with
ctrl+f11
and this seems work well with python run configurations too.
But... What if the last thing I ran was a Java program, but I now want to run the active .py file? Previously, to run the .py file, I'd have to go digging through the buttons on the toolbar with the mouse, and I tend to prefer keyboard shortcuts...
Solution! So, finally I come to the actual useful bit of this answer - I just discovered by accident (typing Ivan's suggested shortcut, but missing!), it appears that
f9
will run the currently active python file.
Hope that helps someone get just that little bit faster...
I use CTRL+SHIFT+F9 to relaunch the previous debug configuration in Pydev.