Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Eclipse VM not terminating caused by child process
Eclipse VM not terminating caused by child process [message #998163] Wed, 09 January 2013 13:27 Go to next message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 17
Registered: December 2012
Junior Member
Hi

I have this program:
public class TestChildProcess {
	public static void main(String[] args) throws Exception {
		Process exec = Runtime.getRuntime().exec( new String[]{
				"cmd",
				"/c",
				"start",
				"notepad.exe"});
		exec.waitFor();
		System.out.println("completed "+exec.exitValue());
		exec.destroy();
	}
}


I want to start a executable from within my java application, and this executable shall stay active after my java program terminates.

If I start this from cmd.exe like
java -cp bin TestChildProcess

the taskmanager on windows does only show the newly created notepad.exe, the java.exe seems to be terminated. Thats like it should be.

However, when I start this program from within Eclipse normal or debugger, the VM stay running until I terminte notepad.exe

What is the reason for this?
Is there a workaround or another way to implenent the behavior I want?
Is this a bug?

Or is the right place to ask? I assumed this may be a problem how JDT is starting/handling the VM.

thanks Frank









Re: Eclipse VM not terminating caused by child process [message #998176 is a reply to message #998163] Wed, 09 January 2013 14:04 Go to previous message
Frank Benoit is currently offline Frank BenoitFriend
Messages: 17
Registered: December 2012
Junior Member
I found a work around...

the problem might be who the windows process is created, it must have the flag DETACH_PROCESS. I found a description in discussions how to start a subversion background hook on windows.

have rundetached.vbs

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run( WScript.Arguments(0) )


Process exec = Runtime.getRuntime().exec( new String[]{
		"cscript",
		"rundetached.vbs",
		"notepad.exe"});


Now, the VM is terminated.

Does anyone know how I could get this behavior without using VBS and depending on cscript.exe?

Frank


Previous Topic:No indication of error/warning with annotated element on annotation processing
Next Topic:Deployment Assembly: The currently displayed page contains invalid values
Goto Forum:
  


Current Time: Fri Apr 19 21:37:36 GMT 2024

Powered by FUDForum. Page generated in 0.02513 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top