java - Getting the output of a subprocess that inherited parent's IO -
i having trouble getting output of subprocess. use process.getinputstream()
. however, in case, set subprocess inherit parent's io. need because output subprocess exceeds buffer set kernel , hang. using linux btw.
//creating named pipe file fifo = fifocreator.createfifopipe("fifo"); string[] command = new string[] {"cat", fifo.getabsolutepath()}; process = new processbuilder(command).inheritio().start(); //inherit io filewriter fw = new filewriter(fifo.getabsolutefile()); bufferedwriter bw = new bufferedwriter(fw); bw.write(boxstring); bw.close(); process.waitfor(); fifocreator.removefifopipe(fifo.tostring()); //gets nothing here stdinput = new bufferedreader(new inputstreamreader(process.getinputstream())); string input = readalllines(stdinput);
ideally want keep in memory since want performance , less trash.
is there way redirect output of subprocess data structure? if not, there way output?
i thinking of creating separate thread gets output stream.
to avoid kernel buffer problem use thread read output in this question. call streamgobbler
Comments
Post a Comment