Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330639

Summary: [launching] Cannot stop external tool by clicking on red square in console view
Product: [Eclipse Project] Platform Reporter: Marko Tomljenovic <marko.tomljenovic>
Component: AntAssignee: Platform-Ant-Inbox <platform-ant-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, Michael_Rennie, remy.suen
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug
Attachments:
Description Flags
Contains the launch configuration where the bug can be reproduced
none
Plugin that overwrites TerminateCommand for proper process killing in windows none

Description Marko Tomljenovic CLA 2010-11-19 03:33:45 EST
Build Identifier: I20100608-0911

When running an external batch script and trying to stop that (using the red square in the console view) it will not stop the tool.

When looking at the process list you can see that only the initially invoked process is killed but not the children. What is necessary is that the "red square" kills the complete process tree of the initially invoked process.

Due to that problem I cannot use the "Run external tools" at all.

Reproducible: Always

Steps to Reproduce:
1. Take the attached project
2. Run the external launch configuration
3. Stop it using the red square in the console view
4. Take a look at the process list. You can see that sleep.exe and tee.exe are still running
Comment 1 Marko Tomljenovic CLA 2010-11-19 03:37:00 EST
Created attachment 183449 [details]
Contains the launch configuration where the bug can be reproduced
Comment 2 Marko Tomljenovic CLA 2011-01-26 07:57:20 EST
Created attachment 187633 [details]
Plugin that overwrites TerminateCommand for proper process killing in windows

The attached plugin first deregisters the CommandAdapterFactory that provides the command for terminating processes within eclipse.
Then a new command factory is registered that provides a customized command for terminating processes recursively under windows.

It is pretty dirty.

A better solution would be to:
1. Provide means to give certain adapter factories a higher priority than other factories for the same adaptable so that the high prio factory is taken instead the first registered one
OR
2. Sort of an extension point for providing a terminate command for terminating processes when created by "Run external tools".
Comment 3 Marko Tomljenovic CLA 2011-01-26 08:06:18 EST
The new plugin only changes the red square stop button in the "Console" view. If the red square from the job in the "Progress" view is klicked the command line call is not killed properly.
Comment 4 Marko Tomljenovic CLA 2011-01-26 08:50:42 EST
(In reply to comment #3)
> The new plugin only changes the red square stop button in the "Console" view.
> If the red square from the job in the "Progress" view is klicked the command
> line call is not killed properly.

The reason for this behaviour is that also the class ProgramLaunchDelegate need to be changed. The respective part to change looks like this:

while (!process.isTerminated()) {
	try {
		if (monitor.isCanceled()) {
--->>>   	process.terminate();
			break;
		}
		Thread.sleep(50);
	} catch (InterruptedException e) {
	}
}

The marked line need to be replaced by a custom implementation so that the process can be killed properly.
Comment 5 Lars Vogel CLA 2019-11-14 02:21:30 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.