Kill Eclipse background operation without killing Eclipse - eclipse

Is there any way to kill an Eclipse background operation without killing Eclipse itself?
Specifically, I want to kill stalled Subclipse SVN operations. Clicking 'cancel' pops up a little Cancel Requested message, but the operation still sits there forever blocking everything else.
This is Eclipse Helios on Windows 7 if that makes any difference.

I was able to unstuck Eclipse (it was stuck on a large file diff) using the following steps.
Preparations: I always start Eclipse with the eclipse-console: Add start parameter -console in eclipse.ini (first line)
The console always remains responsive even when the eclipse UI freezes
I found the following commands in the console: help threads
List all threads: threads
Stop a thread: threads stop THREAD-NAME
UPDATE: I found out, that usually the "main" thread causes the freezing. Thus the solution is:
Type this in the eclipse console:
threads stop main
This will trigger/throw an Exception in that thread, effectively interrupting what it was doing (being stuck).
This might cause other side-effects (depending on what action was interrupted and where), but i had no problems with it so far.

Killing the task from the Progress window (Window->Show View->Other|General->Progress or Alt+Shift+Q, Q | General->Progress).
Then choose the offending thread and click the red square.
Note it sometimes takes a delay before the kill occur, you may also have to kill other thread in there to get what you want. Lastly it does not always work, if this fails I usually just restart eclipse.
Hope this helps

I was able to stop/terminate the hanging SVN commit process by briefly disconnecting the network adapter. This saved me from killing the Eclipse process, which if not terminated gracefully is known to cause other headaches.

If you go to window Progress in Eclipse and click red square to Stop:
and next, red square becomes gray square and process i frozen (Cancel Requested):
You must use Task Manager (Alt+Ctrl+Del on Windows) for kill process. Go to tab Processes, find process javaw.exe* and click End Process.
The result: frozen process in Eclipse was closed but your Eclipse wasn't closed.
* Process with name javaw.exe is for WildFly server. For Subclipse SVN can be another name of proces.

I'm not sure, but from the Debug perspective, you may be able to view the thread that's performing the background operation and kill it from there for quicker exit.

In console window, open "Open OSGi Console" from drop button.
In this console you can type command threads. This will show all running threads.
You can kill process with command threads stop '<Process name>'. Remember to use single apostrophe ' surrounding <Process name>, otherwise it won't work.
For example, I had to type:
threads stop 'Worker-12: Refresh DSLD scripts'

I had a problem where the external compiler I was using froze up when I tried to cancel the build operation. It was stuck in the "Cancel Requested" state. I went to the Windows Task Manager and found my compiler process and terminated it. That allowed Eclipse to continue and successfully cancel the operation.

Keep clicking on clean console, it will show the back ground processes, keep killing one by one.

I made this by opening console in eclipse and typing 'threads'. And then 'threads stop thread-name'.

In Lunux you can list all the Eclipse processes
ps -edf | grep eclipse
Then you choose the child process (the backgound doing Java process) of the main process (the Eclipse GUI Java process) of the starting shell process.
Example:
myself 21821 1222 0 09:28 ? 00:00:00 /local/eclipse/jee-2021-06/eclipse
myself 21839 21821 8 09:28 ? 00:24:53 /usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java -Dosgi.requiredJavaVersion=11 -Dosgi.instance.area.default=#user.home/eclipse-workspace ... much more ...
myself 21965 21839 0 09:29 ? 00:01:48 /usr/lib/jvm/java-11-openjdk-amd64/bin/java -cp /local/eclipse/jee-2021-06/eclipse/../../../../home/myself/.p2/pool/p ... much more ...
The child in the chain of processes is the one with the proc-id 21965. This one you have to kill.
Try kill -2 <proc-id> and, if it did not work, kill -9 <procid>

Related

Customise debugger stop/restart button behavior

I'm using VS Code to write and debug a C++ program binding to libfuse.
Unfortunately, if you kill a libfuse process with SIGKILL, you then have to use sudo umount -f <mountpoint> before you can start the program again. It's a minor nuisance if I have to do this every time I want to stop or restart debugging, especially as I shouldn't have to authenticate to do such a regular task (the sudo is somehow necessary despite the mount occurring as my user).
While I think this is mainly FUSE's fault (it should gracefully recover from a process being ungracefully killed and unmount automatically instead of leaving the directory saying Transport endpoint is not connected), I also think there should be a way to customise VS Code (or any IDE) to run some clean-up when you want to stop debugging.
I've found that entering -exec signal SIGTERM in the Debug Console will gracefully unmount the directory correctly, stop the process and tell VS Code it's no longer debugging (status bar changes back from orange to blue). But I can't seem to find a way to automate this. I've tried using a .gdbinit file, with some inspiration from this question:
handle SIGTERM nostop
# This doesn't work as hook-quit isn't run when quitting via MI mode, which VS Code uses...
define hook-quit
signal SIGTERM
end
But as noted in the linked question, GDB ignores quit hooks when in MI mode, and VS Code uses MI mode.
The ideal solution for me would be if I could put something in a .vscode configuration file telling it to send -exec signal SIGTERM when I click the stop or restart buttons (and then wait for whatever notification it's getting that debugging has stopped, before restarting if applicable) but I imagine there probably isn't an option for that.
Even if the buttons can't be customised, I'd be happy with the ability to have a keybinding that would just send -exec signal SIGTERM to the Debug Console without me having to open said console and enter the command, though the Command Palette doesn't show anything useful here (nothing that looks like it will send a specified Debug Console command), so I don't expect there's a bindable command for that either.
Does anyone have any suggestions? Or would these belong as feature requests over on the VS Code github? Any way to get GDB to respect its quit hook in MI mode, or to get FUSE to gracefully handle its process being killed would be appreciated too.

How to restart an exe when it is exits in windows 10?

I have a process in windows which i am running in startup. Now i need to make it if somehow that process get killed or stopped i need to restart it again in Windows 10?
Is there any way. Process is a HTTP server which if somehow stopped in windows i need to restart it. I have tried of writing a power-shell in which I'll check task-list status of process and then if not found I'll restart but that is not a good way. Please suggest some good way to do it.
I have a golang exe; under a particular scenario my process got killed or stopped i need to start it up again automatically. This has to be done imediately after the exe got killed. What is the best way to achieve this?
I will give you a brief rundown. You can enable Audit Process Termination in local group policy of the machine as shown below. In your case, success audits would be enough. Please note that the pic is for Windows 7. It may change with OS.
Now every time a process gets terminated, a success event will be generated and written to the security eventlog.
This will allow you to create a task scheduler that triggers on the generation of this event that calls a script that would run the process again. Simple right?
Well, you might have some trouble setting that task up especially when you want to pass details about the generating event to the script. This should help you get through that.
You can user Task scheduler for this purpose. There is a option of "restart on failure" which can be selected and whenever your process get failed it will restart again.
Reference :- https://social.technet.microsoft.com/Forums/windowsserver/en-US/4545361c-cc1f-4505-a0a1-c2dcc094109a/restarting-scheduled-task-that-has-failed?forum=winserverManagement

Is there a way to stop eclipse for publishing to server when process has started?

Is there a way to stop Eclipse for publishing / deleting a project from server, if you really want it to stop in between, and not waiting for eternity it to complete it first (like it makes for me at least)? The event blocks every mods on eclipse and if I press cancel nothing really is happening to the upload process.
EDIT1:
Question in short: Can I cancel publishing to Glassfish from Eclipse servers tab in between the processing?
Answer criteria: I am happy with any insights
what could be done when you want to stop in between?
and what happens there under hood forcing the Eclipse to wait the event until end?
It seems that it is not possible to stop the server from deploying to Glassfish, but what you can interrupt is to run manual intervention before Glassfish starts the deployed program.
It is only partial solution but cuts the time to half, at least.
For manual intervention I use:
#!/bin/bash
ASADMIN=(path to Glassfish asadmin executable)
function undeploy_all {
for p in $*; do
echo "Undeploying $p..."
$ASADMIN undeploy $p
done;
}
apps=`$ASADMIN list-applications -t | awk '{print $1;}'`
undeploy_all $apps
and I run this from Cygwin. Takes effect when logs show that services and wars are copied to server generated folder and app is loading its startup stuff to the log file.
Original post about manual intervention:
[1] Undeploy all applications from Glassfish

How to kill Tomcat when running it from Eclipse?

I am running the Tomcat that gets delivered with your Eclipse download (no, I don't want to download and install the entire Tomcat), and sometimes it hangs when stopping or restarting, and the only way I can find to make it work is restarting all my Eclipse. I am using it under Windows.
Is there any way to kill the Tomcat process (which doesn't appear in the Task Manager)?
It appears as javaw.exe in task manager. An alternative is to execute Tomcat/bin/shutdown.bat.
As to the hang problem, are you sure that your webapp isn't spawning unmanaged threads which might be blocking Tomcat's shutdown?
On Windows, if you know the port Tomcat listens to (below, it is 8080), you can find the PID of the Tomcat process and then kill it from cmd:
> netstat -aon | find "8080"
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 2196
TCP [::]:8080 [::]:0 LISTENING 2196
> taskkill /pid 2196 /f
SUCCESS: The process with PID 2196 has been terminated.
I use better way to shutdown tomcat when it is not found in task manager.
1) Download TCPView(only 285kb) from following link.
http://technet.microsoft.com/en-in/sysinternals/bb897437.aspx
2) Extract folder and start TCPView application.
3) Right click on java.exe and select End Process option.
this would stop your tomcat easily.. This tool is very useful in monitoring port usage.
NOTE: Running TOMCATPATH/bin/shutdown.bat may not shutdown Tomcat when it contains some demon or unmanaged
threads. In such cases TCPView works fine without any issues.
You can set a timeout on startup and shutdown for your Tomcat server in Eclipse. If these timeouts are exceeded, Eclipse will pop up a message asking you if you want to kill it, or keep waiting.
To set these, double-click the name of the server in your Servers tab. It'll open a window like this:
There's a Timeouts section on the right hand side. I set startup to a day (so I can debug startup without it timing out), and shutdown to 30 seconds to be generous (usually this can be very short, since most apps can survive a forced shutdown with no issues).
If you use Linux, try the following steps.
List Tomcat processes (e.g., ps aux | grep catalina)
Locate the strings that look like this: myname 2244 5.5 0.3 57020937 2110741 ? Sl Oct03 5160:01 /usr/lib/jvm/java-1.8.0-<...>/bin/java <...> org.apache.catalina.startup.Bootstrap start
Copy-paste everything between /usr/lib/jvm/<...> and <...>.Bootstrap
Add stop at the end of your command and run it
Essentially, you would take the very same command that was used by Eclipse to start Tomcat and modify the last argument to stop Tomcat.

Blackberry with Eclipse - How can I get rid of multiple Debug Servers?

Each time I choose 'run' it creates a DebugServer (in the debug view). Almost all the context menu options are disabled, including 'Terminate' option.
Is there a way to get rid of these without restarting Eclipse (every dozen runs or so)?
Thanks,
Chris.
Normally, after you will Terminate or Disconnect debug session, it will be marked as
<
terminated>
DebugServer [BlackBerry Simulator]
<
disconnected>RIM JVM
and you can remove it with context menu Remove All Terminated
Otherwise something may be wrong with system (conflict with system defence software, wrong BB eJDE setup, insufficient memory/CPU resources etc)
However you can always terminate debug server by killing fledge.exe and BbDevMgr.exe