Skip to content

Commit 36c5776

Browse files
author
codemodify
committed
read lines not bytes
1 parent 5e4be72 commit 36c5776

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Processes/Monitor/procmon-impl.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,16 @@ func readStdOutFromProc(readerCloser io.ReadCloser, process Process) {
252252
"message": fmt.Sprintf("starting to read StdOut: %s", process.Executable),
253253
})
254254

255-
output := make([]byte, 5000)
255+
// output := make([]byte, 5000)
256256

257257
reader := bufio.NewReader(readerCloser)
258-
lengthRead, err := reader.Read(output)
258+
// lengthRead, err := reader.Read(output)
259+
line, _, err := reader.ReadLine()
259260
for err != io.EOF {
260-
process.OnStdOut(output[0:lengthRead])
261-
lengthRead, err = reader.Read(output)
261+
// process.OnStdOut(output[0:lengthRead])
262+
process.OnStdOut(line)
263+
// lengthRead, err = reader.Read(output)
264+
line, _, err = reader.ReadLine()
262265
}
263266

264267
if err != nil {
@@ -275,13 +278,16 @@ func readStdErrFromProc(readerCloser io.ReadCloser, process Process) {
275278
"message": fmt.Sprintf("starting to read StdErr: %s", process.Executable),
276279
})
277280

278-
output := make([]byte, 5000)
281+
// output := make([]byte, 5000)
279282

280283
reader := bufio.NewReader(readerCloser)
281-
lengthRead, err := reader.Read(output)
284+
// lengthRead, err := reader.Read(output)
285+
line, _, err := reader.ReadLine()
282286
for err != io.EOF {
283-
process.OnStdErr(output[0:lengthRead])
284-
lengthRead, err = reader.Read(output)
287+
// process.OnStdOut(output[0:lengthRead])
288+
process.OnStdOut(line)
289+
// lengthRead, err = reader.Read(output)
290+
line, _, err = reader.ReadLine()
285291
}
286292

287293
if err != nil {

0 commit comments

Comments
 (0)