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

Bug 318158

Summary: Eclipse waiting for termination of process tree instead of JVM
Product: [Eclipse Project] JDT Reporter: Kent Tong <kent>
Component: DebugAssignee: JDT-Debug-Inbox <jdt-debug-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: darin.eclipse, remy.suen, sarika.sinha
Version: 3.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Kent Tong CLA 2010-06-28 06:28:27 EDT
Build Identifier: I20070621-1340

Please run the Java program in Eclipse. Even though the JVM is terminated (as shown in the process list in the OS) and the shutdown hook is called, the red button will still be on in the Console window, meaning that Eclipse thinks that something is still running. This happens only if the Java program launches another process.

If I end that child process, Eclipse will note the termination. So, somehow Eclipse is waiting for the whole process tree to terminate, not the JVM.

public class Launcher {
	boolean isDone = false;

	public static void main(String[] args) throws InterruptedException {
		new Launcher().run();
	}

	private void run() throws InterruptedException {
		final Runtime runtime = Runtime.getRuntime();
		Thread thread = new Thread(new Runnable() {

			@Override
			public void run() {
				try {
					Process process = runtime.exec("cmd.exe /c start");
					process.getErrorStream().close();
					process.getOutputStream().close();
					System.out.println("Done!");
					isDone = true;
				} catch (Exception e) {
					throw new RuntimeException(e);
				}
			}

		});
		thread.setDaemon(true);
		thread.start();
		runtime.addShutdownHook(new Thread() {
			@Override
			public void run() {
				System.out.println("Shutdown hook called.");
			}
		});
		while (!isDone) {
			Thread.sleep(1000);
		}
		runtime.exit(0);
	}
}

Reproducible: Always

Steps to Reproduce:
1. Run the above program in Eclipse
2. Note the red button is on, even though the shutdown hook is called
3. End the child process (the command prompt), note that the red button is now off.
Comment 1 Remy Suen CLA 2010-06-28 06:39:03 EDT
This seems to be related to the launching of Java code and has nothing to do with the Eclipse UI.

You also may want to give 3.6 a try.
http://download.eclipse.org/eclipse/downloads/drops/R-3.6-201006080911/index.php
Comment 2 Kent Tong CLA 2010-06-28 06:43:57 EDT
In addition, it is working fine in Linux. The problem only happens in Windows.
Comment 3 Darin Wright CLA 2010-06-28 10:24:01 EDT
The problem does exist on Windows. If I "exit" the lanuched command window then the process in Eclipse shows terminated. This may just be an OS limitation, as Eclipse is simply waiting for the java.lang.Process to exit.
Comment 4 Eclipse Genie CLA 2018-12-09 14:14:05 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.

--
The automated Eclipse Genie.
Comment 5 Sarika Sinha CLA 2018-12-09 23:59:20 EST
We are not planning to fix it.