0

The javadoc of Process says:

The created subprocess does not have its own terminal or console. All its standard io (i.e. stdin, stdout, stderr) operations will be redirected to the parent process through three streams (getOutputStream(), getInputStream(), getErrorStream()).

What is something I'd like to avoid and let the child do it's own stuff with its std streams. Is there any way to avoid the overtake of the streams?

aioobe
  • 413,195
  • 112
  • 811
  • 826
zeller
  • 4,904
  • 2
  • 22
  • 40
  • 1
    What do you mean by *let the child do it's own stuff with its std streams*? – aioobe Jan 10 '13 at 16:08
  • The current case is that I'm starting an OSGi application with a launcher that ensures the adequate conditions for the app. The OSGi process would do some logging to the stdout, but this way the log does not get printed. OK, this may be stupid, but somehow if I run the app with the launcher, other things get wrong... I had a python launcher earlier which was fine and haven't took the streams so as a first guess I blame the stream capture. – zeller Jan 10 '13 at 16:08
  • So you want the output of the external process to be printed on stdout? – aioobe Jan 10 '13 at 21:03
  • Could say that. But ultimately I want to fix the rest of the errors. It seems that the osgi app starts blocking somewhere when it runs with its streams redirected, but I have to investigate it more. – zeller Jan 11 '13 at 06:27
  • I've written some other answers that may be of help then: [answer 1](http://stackoverflow.com/questions/3754841/how-to-make-a-java-program-to-print-both-out-println-and-err-println-stateme), [answer 2](http://stackoverflow.com/questions/5591215/run-external-program-concurrently) and [answer 3](http://stackoverflow.com/questions/3754841/how-to-make-a-java-program-to-print-both-out-println-and-err-println-stateme) – aioobe Jan 11 '13 at 07:33
  • @aioobe: thanks I'll take a look at them later. – zeller Jan 11 '13 at 08:55
  • @aioobe: I've just tried one. And it works! Thanks. The real problem was, that the java.util.Logger of the child process threw uncaught exceptions when the parent wasn't reading the output streams. This was really unexpected, since the neither `console` nor `consoleLog` was specified for the OSGi framework. Maybe the logger config overrode this... – zeller Jan 15 '13 at 10:09

0 Answers0