fix: was reaping too fast?
This commit is contained in:
parent
ededf9aeb5
commit
ab9a10fbe3
@ -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,26 +15,25 @@ 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
|
|
||||||
}
|
|
||||||
initLog.Taintf(log.Warning, "reaper: wait4 failed: %v", err)
|
|
||||||
}
|
|
||||||
if pid <= 0 {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
initLog.Taintf(log.Warning, "reaper: wait4 failed: %v", err)
|
||||||
|
}
|
||||||
|
if pid <= 0 {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user