summaryrefslogtreecommitdiff
path: root/shell.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2019-05-10 02:46:27 +0000
committerJeff Carr <[email protected]>2019-05-10 02:46:27 +0000
commit59c9bf88cace539461f451a318e79feddee8f502 (patch)
tree22eb9b0035516157f48b6c0f18f7c7dfd2f666a3 /shell.go
parent954470c34ce2296c4d534c261f400c4fa9f20900 (diff)
fix stderr (stdout was wrong too)
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'shell.go')
-rw-r--r--shell.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/shell.go b/shell.go
index bfdac21..b1f7d10 100644
--- a/shell.go
+++ b/shell.go
@@ -90,8 +90,6 @@ func Run(cmdline string) int {
newreader := bufio.NewReader(pstdout)
nbr := nbreader.NewNBReader(newreader, 1024)
- // nbrerr := nbreader.NewNBReader(newerrreader, 1024)
-
tmp := bufio.NewReader(pstderr)
go NonBlockingReader(tmp, shellStderr)
@@ -113,15 +111,19 @@ func Run(cmdline string) int {
log.Println("Read() count = ", count, "err = ", err)
oneByte = make([]byte, 1024)
count, err = nbr.Read(oneByte)
- f.Write([]byte(string(oneByte)))
+ log.Println("STDOUT: count = ", count)
+ f.Write(oneByte[0:count])
f.Flush()
empty = true
dead = true
}
- f.Write([]byte(string(oneByte)))
- f.Flush()
+ // f.Write([]byte(string(oneByte)))
if (count == 0) {
empty = true
+ } else {
+ log.Println("STDOUT: count = ", count)
+ f.Write(oneByte[0:count])
+ f.Flush()
}
}
@@ -180,8 +182,10 @@ func NonBlockingReader(buffReader *bufio.Reader, writeFileHandle *os.File) {
log.Println("STDERR: totalCount = ", totalCount)
totalCount = 0
}
+ } else {
+ log.Println("STDERR: count = ", count)
+ writeFileHandle.Write(oneByte[0:count])
}
- writeFileHandle.Write([]byte(string(oneByte)))
}
}
}