mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 01:27:16 +08:00
pkg/terminal: Fix exit status
During a debug session if the process exited and then the user quit the debug session, the process exit message would display again and Delve would exit non-zero (specifically with exit code 1) despite nothing going wrong. This patch fixes this so that Delve exits with a clean 0 status and the process exit message is not printed yet again.
This commit is contained in:
committed by
Alessandro Arzilli
parent
7e2660e7de
commit
c119e40c6d
@ -281,6 +281,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) {
|
func TestScopePrefix(t *testing.T) {
|
||||||
if runtime.GOARCH == "arm64" {
|
if runtime.GOARCH == "arm64" {
|
||||||
t.Skip("arm64 does not support Stacktrace for now")
|
t.Skip("arm64 does not support Stacktrace for now")
|
||||||
|
|||||||
@ -354,7 +354,8 @@ func (t *Term) handleExit() (int, error) {
|
|||||||
|
|
||||||
s, err := t.client.GetState()
|
s, err := t.client.GetState()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if isErrProcessExited(err) && t.client.IsMulticlient() {
|
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] ")
|
answer, err := yesno(t.line, "Remote process has exited. Would you like to kill the headless instance? [Y/n] ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 2, io.EOF
|
return 2, io.EOF
|
||||||
@ -366,6 +367,8 @@ func (t *Term) handleExit() (int, error) {
|
|||||||
}
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
return 1, err
|
return 1, err
|
||||||
}
|
}
|
||||||
if !s.Exited {
|
if !s.Exited {
|
||||||
|
|||||||
Reference in New Issue
Block a user