-
Bug
-
Resolution: Fixed
-
P2
-
1.1.3
-
1.2
-
sparc
-
solaris_2.5.1
-
Not verified
JLS Sec 20.16.6 reads
Given an array of strings cmdarray, representing the
tokens of a command line, and an array of strings envp,
representing an "environment" that defines system
properties, this method creates a new process in which
to execute the specified command and returns a Process
object (§20.15) representing the new process.
envp is the operating system specific environment strings,
and not system properties. The following piece of code:
String[] env = { "foo=bar", "bar=foo" };
Runtime.getRuntime().exec("ls", env);
sets the "char *envp[]" of main() in the "ls" program.
One user tried to exec a java program instead of "ls" and
excepted his Java program to be able to get at envp values
via System.getProperty(), which is what a reading of the
spec seems to imply (see part 2 of evaluation in bug
4061350). Since Runtime.exec can exec arbitrary programs
which don't care or know about "system properties", the JLS
is wrong, and what the code does is correct.
anand.palaniswamy@Eng 1997-08-26
Given an array of strings cmdarray, representing the
tokens of a command line, and an array of strings envp,
representing an "environment" that defines system
properties, this method creates a new process in which
to execute the specified command and returns a Process
object (§20.15) representing the new process.
envp is the operating system specific environment strings,
and not system properties. The following piece of code:
String[] env = { "foo=bar", "bar=foo" };
Runtime.getRuntime().exec("ls", env);
sets the "char *envp[]" of main() in the "ls" program.
One user tried to exec a java program instead of "ls" and
excepted his Java program to be able to get at envp values
via System.getProperty(), which is what a reading of the
spec seems to imply (see part 2 of evaluation in bug
4061350). Since Runtime.exec can exec arbitrary programs
which don't care or know about "system properties", the JLS
is wrong, and what the code does is correct.
anand.palaniswamy@Eng 1997-08-26
- relates to
-
JDK-4061350 Runtime.exec() - envp[] not passed correctly
- Closed