@@ -358,6 +358,7 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) (err error) {
358
358
}
359
359
}
360
360
361
+ startTime := time .Now ()
361
362
err = cmd .Start ()
362
363
if stdoutW != nil {
363
364
// The child process has inherited the pipe file,
@@ -384,7 +385,7 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) (err error) {
384
385
case err := <- resChan :
385
386
return err
386
387
case <- timer .C :
387
- HandleHangingGoCommand (cmd . Process )
388
+ HandleHangingGoCommand (startTime , cmd )
388
389
case <- ctx .Done ():
389
390
}
390
391
} else {
@@ -418,7 +419,7 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) (err error) {
418
419
return <- resChan
419
420
}
420
421
421
- func HandleHangingGoCommand (proc * os. Process ) {
422
+ func HandleHangingGoCommand (start time. Time , cmd * exec. Cmd ) {
422
423
switch runtime .GOOS {
423
424
case "linux" , "darwin" , "freebsd" , "netbsd" :
424
425
fmt .Fprintln (os .Stderr , `DETECTED A HANGING GO COMMAND
@@ -451,7 +452,7 @@ See golang/go#54461 for more details.`)
451
452
panic (fmt .Sprintf ("running %s: %v" , listFiles , err ))
452
453
}
453
454
}
454
- panic (fmt .Sprintf ("detected hanging go command (pid %d): see golang/go#54461 for more details " , proc .Pid ))
455
+ panic (fmt .Sprintf ("detected hanging go command (golang/go#54461); waited %s \n \t command:%s \n \t pid:%d " , time . Since ( start ), cmd , cmd . Process .Pid ))
455
456
}
456
457
457
458
func cmdDebugStr (cmd * exec.Cmd ) string {
0 commit comments