Fix shell shutdown (?)

At least on the alternative hardware, things happen this way:
1. The shell 'exit' command has ptyOut signal outputComplete and terminate. At this point, ptyIn is still blocked up to one second in ReadCharacter - and can therefore not react on outputComplete.
2. The outputComplete handler in ShellCommand sends a zero byte. This makes on the A2 DumpOutput return and the caller send a zero byte. ShellCommand must not return here as ptyIn is still blocked.
3. The zero byte from the A2 has ptyIn return from ReadCharacter, signal userCancelled and terminate.
4. ShellCommand can now return, but it must not send a zero byte, as the A2 is not expecting it - and will therefore later misinterpret it.

Maybe the original hardware needs another handling, then differentiation of behavior in shell.go becomes necessary.
This commit is contained in:
Oliver Schmidt 2022-08-19 23:46:09 +02:00 committed by Terence Boldt
parent 3f33641904
commit 7b3c5a13c3
1 changed files with 3 additions and 2 deletions

View File

@ -45,12 +45,13 @@ func ShellCommand() {
case <-outputComplete:
ptmx.Close()
comm.WriteByte(0)
return
// return
break
case <-userCancelled:
fmt.Printf("User cancelled, killing process\n")
ptmx.Close()
cmd.Process.Kill()
comm.WriteByte(0)
// comm.WriteByte(0)
return
case <-inputComplete:
cmd.Wait()