I know the answer depends on the particular JVM, but I would like to understand how it is usually implemented? Is it in terms of popen (posix)? In terms of efficiency do I need to keep something in mind (other than using a Buffered stream as suggested by the javadoc). I would be interested to know if there is a general reference about implementations of JVMs which answers such questions.
Share
Look at the source of JDK.
In this case, for Unix, look at UnixProcess class.it does a fork and exec and wraps file and buffer streams around native file descriptors.
For native code look at:
native/java/lang/UNIXProcess_md.c
It does something interesting!
it opens pipes and give them as STDIN, STDOUT, STDERR to child and other side of pipes are used by parent!
In short IPC mechanism is pipes.