in reply to Trapping Java Errors
This sounds like the kind of thing that I have used IPC::Open3 for in the past. Now be aware that doing this is somewhat tricky. As soon as you use that module you need to figure out how to handle STDIN, STDOUT, and STDERR. Just to make life fun, if are trying to read on one of the pipes while it tries to write on another, you may be waiting for a good while. Also you need to think about the fact that when the poor child dies you need to reap it with wait or waitpid.
This definitely deserves a generic "run_system" command. And since all errors will be coming from there, you want to use Carp and confess to any problems.
Therefore I recommend looking for ways to not have to do that work yourself. (Push it off to the OS. After all that is why you have one!) Personally I would use File::Spec to pick up the devnull function to get null data for STDIN. I would use File::Temp to create a tempfile for STDERR (which you can seek on then read at your leisure), and I would read STDOUT yourself.
Then your pattern looks like this:
|
|---|