Article View: borland.public.jbuilder.java.api
Article #2020Problem terminate started process with the Runtime class
From: Kristian
Date: Mon, 25 Jun 2001 18:00
Date: Mon, 25 Jun 2001 18:00
62 lines
2919 bytes
2919 bytes
Hi!
...I would be very thankfull if someone could help me with the following
problem with the Runtime class:
I have created a "Process Launcher" in JBuilder which main task is to start
a process (a server program).
The server needs a file (configuration purpose) as input and the output is
usually stored in a file:
*server configFile >>&logFile
(Append to the logfile which exist and read both from stdout and stderr).
So therefore I load an executable file and a configuration file in my GUI
and after this
I start this process and continously read from it and highlights different
keywords etc.
But my problem is that I can't destroy the process I just started? (believe
it or not ;-) )
I'm using the Process class in Java because I thought it had nice
functions that satisfied my requirements. Here is what it's look like:
Start the process:
proc = Runtime.getRuntime().exec(new String[] { "tcsh", "-c", executableFile
+ " " + cfgFile + " >>&.logfile"});
// Contiously read the logfile in a separate thread
....
// When finished, try to destroy the process:
proc.destroy();
But the server process will not terminate...But this isn't a surprise
because the only process that terminates is
the tcshell.
If I use it together with proc.waitFor(); , which should return 0 on success
it returns 15 in my case?
But shouldn't there be a way to come around this problem and also manage to
terminate the second process, ie.
the executableFile (the server in my case)?
Ofcourse, at the beginning, I didn't made it so hard for me and simple
tried:
proc = Runtime.getRuntime().exec(executableFile + " " + cfgFile + "
>>&.logfile");
But it didn't succeed?
As I said, I would be very glad if someone has a solution to this problem
and could tell me (and others) about it.
I know script files could be a solution but since this is the only problem
left in my GUI program I think it would be
nice to keep the rest of it as it is today. And hopefully, it is an easy
problem to solve for someone who sees something
that I have missed(?).
Best regard
Kristian
Technical Details
Message-ID:
<3b377c03_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,83b38d347febae6b,start X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2001-06-25 11:08:40 PST From: "Kristian" <kristian@nr1.nu> Newsgroups: borland.public.jbuilder.java.api Subject: Problem terminate started process with the Runtime class Date: Mon, 25 Jun 2001 20:00:44 +0200 Lines: 65 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 NNTP-Posting-Host: 213.88.177.32 Message-ID: <3b377c03_1@dnews> X-Trace: dnews 993491971 213.88.177.32 (25 Jun 2001 10:59:31 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews