How to identify that command has finished executing?
supacoda10 opened this issue · comments
supacoda10 commented
I am trying to run a command and send the output via websocket. Below is my code. The issue is it never ends even after the command has completed executing. How to identify that the command has finished executing?
cmd := exec.Command("docker-compose", "-p", "myproject", "-f", "/tmp/myproject/compose.yaml", "pull")
f, err := pty.Start(cmd)
if err != nil {
log.Error().Err(err).Msg("pty returned error")
return err
}
b := make([]byte, 1024)
for {
n, err := f.Read(b)
if n == 0 {
break
}
if err != nil {
if err != io.EOF {
log.Error().Err(err).Msg("Error while reading from pty")
}
break
}
ws.WriteMessage(websocket.BinaryMessage, b[:n])
}
// Code never reaches here
supacoda10 commented
Sorry, I am using https://github.com/gabemarshall/pty which has this issue only on Windows. So closing.
Any plans to support Windows in creack/pty?