@@ -494,6 +494,16 @@ func signalAllProcesses(m cgroups.Manager, s os.Signal) error {
494494 logrus .Warn (err )
495495 }
496496
497+ subreaper , err := system .GetSubreaper ()
498+ if err != nil {
499+ // The error here means that PR_GET_CHILD_SUBREAPER is not
500+ // supported because this code might run on a kernel older
501+ // than 3.4. We don't want to throw an error in that case,
502+ // and we simplify things, considering there is no subreaper
503+ // set.
504+ subreaper = 0
505+ }
506+
497507 for _ , p := range procs {
498508 if s != unix .SIGKILL {
499509 if ok , err := isWaitable (p .Pid ); err != nil {
@@ -507,9 +517,16 @@ func signalAllProcesses(m cgroups.Manager, s os.Signal) error {
507517 }
508518 }
509519
510- if _ , err := p .Wait (); err != nil {
511- if ! isNoChildren (err ) {
512- logrus .Warn ("wait: " , err )
520+ // In case a subreaper has been setup, this code must not
521+ // wait for the process. Otherwise, we cannot be sure the
522+ // current process will be reaped by the subreaper, while
523+ // the subreaper might be waiting for this process in order
524+ // to retrieve its exit code.
525+ if subreaper == 0 {
526+ if _ , err := p .Wait (); err != nil {
527+ if ! isNoChildren (err ) {
528+ logrus .Warn ("wait: " , err )
529+ }
513530 }
514531 }
515532 }
0 commit comments