diff --git a/pkg/terminal/command_test.go b/pkg/terminal/command_test.go
index 14fb795..350347f 100644
--- a/pkg/terminal/command_test.go
+++ b/pkg/terminal/command_test.go
@@ -278,6 +278,19 @@ func TestIssue411(t *testing.T) {
})
}
+func TestExitStatus(t *testing.T) {
+ withTestTerminal("continuetestprog", t, func(term *FakeTerminal) {
+ term.Exec("continue")
+ status, err := term.handleExit()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if status != 0 {
+ t.Fatalf("incorrect exit status, expected 0, got %d", status)
+ }
+ })
+}
+
func TestScopePrefix(t *testing.T) {
const goroutinesLinePrefix = " Goroutine "
const goroutinesCurLinePrefix = "* Goroutine "
diff --git a/pkg/terminal/terminal.go b/pkg/terminal/terminal.go
index cb59de9..b8ae4d8 100644
--- a/pkg/terminal/terminal.go
+++ b/pkg/terminal/terminal.go
@@ -354,17 +354,20 @@ func (t *Term) handleExit() (int, error) {
s, err := t.client.GetState()
if err != nil {
- if isErrProcessExited(err) && t.client.IsMulticlient() {
- answer, err := yesno(t.line, "Remote process has exited. Would you like to kill the headless instance? [Y/n] ")
- if err != nil {
- return 2, io.EOF
- }
- if answer {
- if err := t.client.Detach(true); err != nil {
- return 1, err
+ if isErrProcessExited(err) {
+ if t.client.IsMulticlient() {
+ answer, err := yesno(t.line, "Remote process has exited. Would you like to kill the headless instance? [Y/n] ")
+ if err != nil {
+ return 2, io.EOF
+ }
+ if answer {
+ if err := t.client.Detach(true); err != nil {
+ return 1, err
+ }
}
+ return 0, err
}
- return 0, err
+ return 0, nil
}
return 1, err
}