New methods in jdk7

Martin Buchholz martinrb at google.com
Wed Oct 7 06:55:46 UTC 2009


On Tue, Oct 6, 2009 at 09:40, Paulo Levi <i30817 at gmail.com> wrote:
> I thought there was the danger of deadlocks if the std.out and std.err
> wasn't drained?

Well, yes, there is a danger of deadlocks, but this can be avoided by:
- having separate threads read stdout and stderr
- closing the various streams in the parent (but might cause child to exit)
- using redirectErrorStream
- using new redirection facilities in jdk7
http://download.java.net/jdk7/docs/api/java/lang/ProcessBuilder.html

> To be clear, you're saying that if i call this, and allow the parent
> to be killed (by throwing a Error for instance), the child process
> lives still? (I believe i can't call System.exit(1) without all jvm
> dying right?)

Why not try it?  System.exit should only cause one jdk to exit directly.

Martin



More information about the core-libs-dev mailing list