Try to resolve #171
This commit is contained in:
parent
594a02115b
commit
9a49f753d9
|
@ -112,8 +112,8 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
data["succ"] = false
|
||||
}
|
||||
|
||||
outReader := util.NewReader(stdout)
|
||||
errReader := util.NewReader(stderr)
|
||||
outReader := bufio.NewReader(stdout)
|
||||
errReader := bufio.NewReader(stderr)
|
||||
|
||||
if err := cmd.Start(); nil != err {
|
||||
logger.Error(err)
|
||||
|
@ -167,12 +167,18 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
go func() {
|
||||
for {
|
||||
buf, err := outReader.ReadData()
|
||||
r, _, err := outReader.ReadRune()
|
||||
|
||||
if nil == session.OutputWS[sid] {
|
||||
break
|
||||
}
|
||||
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
buf := string(r)
|
||||
buf = strings.Replace(buf, "<", "<", -1)
|
||||
buf = strings.Replace(buf, ">", ">", -1)
|
||||
|
||||
// TODO: fix the duplicated error
|
||||
|
||||
if nil != err {
|
||||
// remove the exited process from user process set
|
||||
processes.remove(wSession, cmd.Process)
|
||||
|
@ -209,9 +215,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}()
|
||||
|
||||
for {
|
||||
buf, err := errReader.ReadData()
|
||||
buf = strings.Replace(buf, "<", "<", -1)
|
||||
buf = strings.Replace(buf, ">", ">", -1)
|
||||
r, _, err := errReader.ReadRune()
|
||||
|
||||
if nil == session.OutputWS[sid] {
|
||||
break
|
||||
|
@ -219,6 +223,10 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
buf := string(r)
|
||||
buf = strings.Replace(buf, "<", "<", -1)
|
||||
buf = strings.Replace(buf, ">", ">", -1)
|
||||
|
||||
if nil != err {
|
||||
// remove the exited process from user process set
|
||||
processes.remove(wSession, cmd.Process)
|
||||
|
|
Loading…
Reference in New Issue