Skip to content

Commit

Permalink
fix panicwrap parent check (#6264)
Browse files Browse the repository at this point in the history
  • Loading branch information
parasssh authored Aug 27, 2020
1 parent 3cea0fe commit 52e136f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions x/sentry_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,17 @@ func WrapPanics() {
if err != nil {
panic(err)
}
// If exitStatus >= 0, then we're the parent process and the panicwrap
// re-executed ourselves and completed. Just exit with the proper status.
if exitStatus >= 0 {

// Note: panicwrap.Wrap documentation states that exitStatus == -1
// should be used to determine whether the process is the child.
// However, this is not reliable. See https://github.com/mitchellh/panicwrap/issues/18
// we have found that exitStatus = -1 is returned even when
// the process is the parent. Likely due to panicwrap returning
// syscall.WaitStatus.ExitStatus() as the exitStatus, which _can_ be
// -1. Checking panicwrap.Wrapped(nil) is more reliable.
if !panicwrap.Wrapped(nil) {
// parent
os.Exit(exitStatus)
}
// child
}

0 comments on commit 52e136f

Please sign in to comment.