fix: was reaping too fast?

This commit is contained in:
Mikaël Cluseau 2018-07-11 09:40:04 +11:00
parent ededf9aeb5
commit ab9a10fbe3

View File

@ -3,6 +3,7 @@ package main
import ( import (
"os" "os"
"os/signal" "os/signal"
"syscall"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"novit.nc/direktil/pkg/log" "novit.nc/direktil/pkg/log"
@ -14,17 +15,17 @@ func handleChildren() {
initLog.Taintf(log.Error, "reaper: failed to set myself a child sub-reaper: %v", err) initLog.Taintf(log.Error, "reaper: failed to set myself a child sub-reaper: %v", err)
} }
sigchld := make(chan os.Signal, 10) sigchld := make(chan os.Signal, 2048)
signal.Notify(sigchld, unix.SIGCHLD) signal.Notify(sigchld, syscall.SIGCHLD)
for range sigchld { for range sigchld {
// reap children reapChildren()
var ( }
ws unix.WaitStatus }
rus unix.Rusage
) func reapChildren() {
for { for {
pid, err := unix.Wait4(-1, &ws, unix.WNOHANG, &rus) pid, err := syscall.Wait4(-1, nil, syscall.WNOHANG, nil)
if err != nil { if err != nil {
if err == unix.ECHILD { if err == unix.ECHILD {
break break
@ -36,4 +37,3 @@ func handleChildren() {
} }
} }
} }
}