Category Archives: programming

Runtime.exec() is not fork(2)

I had a process which would hang when executed from Java using Runtime.exec(). Running strace showed the process hanging on a write system call. The problem is that Runtime.exec() in Java does not just fork and execute a process, it also redirects stdio to the parent Java process. So using BufferedReader and Process. I just piped the stdout of the child process to System.out.

This is all explained in http://download.java.net/jdk7/docs/api/java/lang/Process.html

Advertisements