#Problem faced
I am new to Scala and rusty in Java.
When running the top command it throws an exception that I am not capturing properly and I dont see where the error seems to be or how could I correct it. As you can see in the output, the results are given properly, but the exception is always thrown. Ideas?
I/O error Pipe closed for process: [top, -b1]
java.io.IOException: Pipe closed
at java.io.PipedInputStream.checkStateForReceive(PipedInputStream.java:260)
at java.io.PipedInputStream.awaitSpace(PipedInputStream.java:268)
at java.io.PipedInputStream.receive(PipedInputStream.java:231)
at java.io.PipedOutputStream.write(PipedOutputStream.java:149)
at scala.sys.process.BasicIO$.loop$1(BasicIO.scala:236)
at scala.sys.process.BasicIO$.transferFullyImpl(BasicIO.scala:242)
at scala.sys.process.BasicIO$.transferFully(BasicIO.scala:223)
at scala.sys.process.ProcessImpl$PipeThread.runloop(ProcessImpl.scala:159)
at scala.sys.process.ProcessImpl$PipeSource.run(ProcessImpl.scala:179)
Total Memory [7,69 GB]
Used Memory [7,45 GB]
Free Memory [0,24 GB]
Available Memory [0,00 GB]
The use of
.lines
/.lineStrem
was solving the issue, thank you but it seems the main problem was a bad use of the top command parameters. When using the wrong top command but capturing theStream[String]
, the execution was taking long time due to the nature of the top command in batches.This solves it. Setting
top
as returning one and only batchhttps://github.com/miguelsaddress/SystemInfoParser/blob/cf805e8eaa147ff84d4390c6bc06457fcd38dfac/src/main/scala/com/mamoreno/systemInfo/os/MacOsInfo.scala#L26
Thanks for your help ^_^