@@ -78,7 +78,7 @@ type WrapConfig struct {
7878// BasicWrap calls Wrap with the given handler function, using defaults
7979// for everything else. See Wrap and WrapConfig for more information on
8080// functionality and return values.
81- func BasicWrap (f HandlerFunc ) (int , error ) {
81+ func BasicWrap (f HandlerFunc ) (done bool , statusCode int , err error ) {
8282 return Wrap (& WrapConfig {
8383 Handler : f ,
8484 })
@@ -87,7 +87,7 @@ func BasicWrap(f HandlerFunc) (int, error) {
8787// Wrap wraps the current executable in a handler to catch panics. It
8888// returns an error if there was an error during the wrapping process.
8989// If the error is nil, then the int result indicates the exit status of the
90- // child process. If the exit status is -1 , then this is the child process,
90+ // child process. If the done flag is false , then this is the child process,
9191// and execution should continue as normal. Otherwise, this is the parent
9292// process and the child successfully ran already, and you should exit the
9393// process with the returned exit status.
@@ -97,9 +97,9 @@ func BasicWrap(f HandlerFunc) (int, error) {
9797//
9898// Once this is called, the given WrapConfig shouldn't be modified or used
9999// any further.
100- func Wrap (c * WrapConfig ) (int , error ) {
100+ func Wrap (c * WrapConfig ) (done bool , statusCode int , err error ) {
101101 if c .Handler == nil {
102- return - 1 , errors .New ("Handler must be set" )
102+ return false , - 1 , errors .New ("Handler must be set" )
103103 }
104104
105105 if c .DetectDuration == 0 {
@@ -112,13 +112,13 @@ func Wrap(c *WrapConfig) (int, error) {
112112
113113 // If we're already wrapped, exit out.
114114 if Wrapped (c ) {
115- return - 1 , nil
115+ return false , - 1 , nil
116116 }
117117
118118 // Get the path to our current executable
119119 exePath , err := os .Executable ()
120120 if err != nil {
121- return - 1 , err
121+ return false , - 1 , err
122122 }
123123
124124 // Pipe the stderr so we can read all the data as we look for panics
@@ -165,7 +165,7 @@ func Wrap(c *WrapConfig) (int, error) {
165165 }
166166
167167 if err := cmd .Start (); err != nil {
168- return 1 , err
168+ return true , 1 , err
169169 }
170170
171171 // Listen to signals and capture them forever. We allow the child
@@ -197,7 +197,7 @@ func Wrap(c *WrapConfig) (int, error) {
197197 exitErr , ok := err .(* exec.ExitError )
198198 if ! ok {
199199 // This is some other kind of subprocessing error.
200- return 1 , err
200+ return true , 1 , err
201201 }
202202
203203 exitStatus := 1
@@ -218,10 +218,10 @@ func Wrap(c *WrapConfig) (int, error) {
218218 c .Handler (panicTxt )
219219 }
220220
221- return exitStatus , nil
221+ return true , exitStatus , nil
222222 }
223223
224- return 0 , nil
224+ return true , 0 , nil
225225}
226226
227227// Wrapped checks if we're already wrapped according to the configuration
0 commit comments