[267] in java-interest
Re: join/exec problem
daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Sat Jun 10 01:31:32 1995
From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
To: majordom@java.Eng.Sun.COM (David Gourley)
Date: Fri, 9 Jun 1995 22:15:03 -0800 (PDT)
Cc: java-interest@java.Eng.Sun.COM
In-Reply-To: <199506100432.VAA00982@dawn0.CS.Berkeley.EDU> from "David Gourley" at Jun 9, 95 09:32:44 pm
Hi David,
> I am having a slight problem using java's exec routines and I was
> wondering if any of you might be able to help me out. I have to
> execute systems commands withing my java app, the problem is that
> if java executes to quickly then race conditions exist for the
> system commands. Basically I need to do something like:
>
> Join(Exec("process foo"));
> // now run the next command
> Join(Exec("process bar"));
>
> Thread join does not seem to help here since I am executing a call
> that once executed is not "part" of the java process. Anyone have
> a solution to this? Thanks for any replies.
Have you tried using System.execin()? It returns an InputStream that
you can read from. I suspect that the InputStream will be closed when
the process terminates. What really should happen is that System.exec
returns a Process object represention the external process. It could
have methods for getting its status. Maybe we can introduce this in
the beta release?
Have fun,
Arthur van Hoff (avh@eng.sun.com)
http://java.sun.com/people/avh/
Sun Microsystems Inc, M/S UPAL02-301,
100 Hamilton Avenue, Palo Alto CA 94301, USA
Tel: +1 415 473 7242, Fax: +1 415 473 7104
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com