Files
java-core-examples/process-api/output/04-environment.txt
T

22 lines
999 B
Plaintext

== 1. the child inherits a COPY of our environment
child sees : GREETING=hello MODE=
our own env: GREETING=null (unchanged)
== 2. clear() and rebuild: pass only what the child needs
child sees : HOME=[] PATH=[/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin] MODE=[minimal]
== 3. which PATH finds the program? start() uses OURS; the child's PATH is for the child
start("date") with child PATH=/nonexistent : true (resolved with the parent's PATH)
sh -c 'date +%Y' with child PATH=/nonexistent : sh: 1: date: not found
== 4. working directory
ls in temp dir: marker.txt
bad directory -> IOException: Cannot run program "ls" (in directory "/no/such/dir"): Exec failed, error: 2 (No such file or directory)
== 5. redirect to files: no pipe, so nothing to drain
exit 0, file contains: to-stdout | to-stderr |
getInputStream() on a redirected process is a null stream: read() = -1
== 6. stdin: close it, or a reader like cat never sees EOF
cat echoed: line one | line two | exit 0