cmd/dlv: fix exit status for trace subcommand (#3263)

We currently return an error when the command exits because a process
exited error is always returned. Detect this like we do in other code
paths to return a 0 exit code instead of nonzero which indicates the
command itself failed and can confuse other tools.
This commit is contained in:
Derek Parker 2023-02-02 02:11:31 -08:00 committed by GitHub
parent 436fed8ec4
commit 98f6d0b619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

@ -732,7 +732,9 @@ func traceCmd(cmd *cobra.Command, args []string) {
err = cmds.Call("continue", t)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return 1
if !strings.Contains(err.Error(), "exited") {
return 1
}
}
return 0
}()

@ -1038,7 +1038,7 @@ func TestTrace2(t *testing.T) {
if !bytes.Contains(output, expected) {
t.Fatalf("expected:\n%s\ngot:\n%s", string(expected), string(output))
}
cmd.Wait()
assertNoError(cmd.Wait(), t, "cmd.Wait()")
}
func TestTraceMultipleGoroutines(t *testing.T) {