Implement stringer for ExitStatus

PiperOrigin-RevId: 377370807
This commit is contained in:
Tamir Duberstein
2021-06-03 14:18:22 -07:00
committed by gVisor bot
parent 758713f4c1
commit b3c608ef85
+18
View File
@@ -28,6 +28,7 @@ import (
"errors"
"fmt"
"strconv"
"strings"
"gvisor.dev/gvisor/pkg/abi/linux"
"gvisor.dev/gvisor/pkg/sentry/arch"
@@ -50,6 +51,23 @@ type ExitStatus struct {
Signo int
}
func (es ExitStatus) String() string {
var b strings.Builder
if code := es.Code; code != 0 {
if b.Len() != 0 {
b.WriteByte(' ')
}
_, _ = fmt.Fprintf(&b, "Code=%d", code)
}
if signal := es.Signo; signal != 0 {
if b.Len() != 0 {
b.WriteByte(' ')
}
_, _ = fmt.Fprintf(&b, "Signal=%d", signal)
}
return b.String()
}
// Signaled returns true if the ExitStatus indicates that the exiting task or
// thread group was killed by a signal.
func (es ExitStatus) Signaled() bool {