Merge pull request #29 from c0b/resolve-zombies-in-container

loop reaping dead children
master
shengxiang 7 years ago committed by GitHub
commit ed9230e76b

@ -3,6 +3,7 @@
package main package main
import ( import (
"log"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
@ -23,6 +24,18 @@ func watchChildSignal() {
} }
func reapChildren() { func reapChildren() {
var wstatus syscall.WaitStatus for {
syscall.Wait4(-1, &wstatus, syscall.WNOHANG, nil) var wstatus syscall.WaitStatus
wpid, err := syscall.Wait4(-1, &wstatus, syscall.WNOHANG, nil)
if err != nil {
log.Printf("syscall.Wait4 call failed: %v", err)
break
}
if wpid != 0 {
log.Printf("reap dead child: %d, wstatus: %#08x", wpid, wstatus)
} else {
break
}
}
} }

Loading…
Cancel
Save