Today, after maybe two years, I figured out, why one particular piece of code works excellent on Windows, but has been causing a lot of trouble on Linux. That piece of code is the class Executor in my Java application framework library afw.
The reason turned out to be, that the method Process.waitFor() behaves differently on Windows, and Linux, with regard to the launched processes output.
- On Windows, the waitFor() method waits, until
- the launched process has terminated, and
- the processes standard output, and error output has been consumed (in other words: The input streams, as returned by Process.getInputStream(), and Process.getErrorStream() have been read.
- On Linux, however
- The method waits, again, until the launched process has terminated, but
- It doesn't wait for the consumption of the processes output.
- both threads have received EOF from their respective input streams, and
- the invocation of Process.waitFor() has returned.