Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"runtime/debug"
"strconv"
"strings"

"github.com/mitchellh/go-ps"
)

// AllowExit lets you disable the call to os.Exit() in ExitXxx() functions of this package.
Expand Down Expand Up @@ -66,14 +64,14 @@ func ExitError(err error) {
// The function will recover from the condition and exit with a proper UNKNOWN status, while showing error
// and the call stack.
func CatchPanic() {
ppid := os.Getppid()
if parent, err := ps.FindProcess(ppid); err == nil {
if parent.Executable() == "dlv" {
// seems to be a debugger, don't continue with recover
return
}
}

// This can be enabled when working with a debugger
// ppid := os.Getppid()
// if parent, err := ps.FindProcess(ppid); err == nil {
// if parent.Executable() == "dlv" {
// // seems to be a debugger, don't continue with recover
// return
// }
// }
if r := recover(); r != nil {
output := fmt.Sprint("Golang encountered a panic: ", r)
if PrintStack {
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/NETWAYS/go-check
go 1.14

require (
github.com/mitchellh/go-ps v1.0.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
Expand Down