Eclipse VM not terminating caused by child process [message #998163] |
Wed, 09 January 2013 08:27  |
Eclipse User |
|
|
|
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 09:04  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03575 seconds