ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Louis Tribble <>
Subject Re: <arg>
Date Thu, 10 Aug 2000 21:29:41 GMT
Jose Alberto Fernandez wrote:
> I think Runtime.exec replaces completely the current environment
> with what you pass, as oppose to adding to the environment.
> This to me is a major BUG on the API making Runtime.exec() with environment
> almost useless. How can anyone ADD to the environment of a call if there is
> no way to know what was there before?
> Am I off the ball here? Is this a bug in certain implementations or a bug in
> the spec? Is the spec not precise enough?

Neither the javadocs nor the Chan book seems to speak to this, but your
observation seems to be how it works on the ground. If envp is null (or 
empty; I don't know if _that_ bug has been fixed), you get the current 
environment. Otherwise envp replaces the current environment. To exec a 
subprocess that requires a mix of environment variables inherited as is
from the parent process and environment variables modified to suit (for
example, CLASSPATH), I've found only two choices: (1) use envp and
arrange for the launcher of the parent process to pass in all the
environment variables that the subprocess needs as properties or in
a file; or (2) not use envp, exec a script, and pass the modified 
environment variables on the command line for the script to install
before doing it's real work. Both a royal pain.

Tnere are lots of exec bugs on the Bug Parade. One that summarizes a
lot of the problems:

Mo Dejong (now of RedHat) had a nice proposal for making exec less
platform dependent:

Unfortunately, when directory changing was added to JDK 1.3, this bug was 
closed with a promise to open another for the rest of the suggestion, but 
I didn't see the promised successor.


Louis Tribble                               
Metamata, Inc.                         
Tools for serious Java developers.                       +1 510 796 0915

View raw message