fix: was reaping too fast?
This commit is contained in:
parent
ededf9aeb5
commit
ab9a10fbe3
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
"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)
|
||||
}
|
||||
|
||||
sigchld := make(chan os.Signal, 10)
|
||||
signal.Notify(sigchld, unix.SIGCHLD)
|
||||
sigchld := make(chan os.Signal, 2048)
|
||||
signal.Notify(sigchld, syscall.SIGCHLD)
|
||||
|
||||
for range sigchld {
|
||||
// reap children
|
||||
var (
|
||||
ws unix.WaitStatus
|
||||
rus unix.Rusage
|
||||
)
|
||||
reapChildren()
|
||||
}
|
||||
}
|
||||
|
||||
func reapChildren() {
|
||||
for {
|
||||
pid, err := unix.Wait4(-1, &ws, unix.WNOHANG, &rus)
|
||||
pid, err := syscall.Wait4(-1, nil, syscall.WNOHANG, nil)
|
||||
if err != nil {
|
||||
if err == unix.ECHILD {
|
||||
break
|
||||
@ -35,5 +36,4 @@ func handleChildren() {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user