You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gosuv/sigchld_unix.go

29 lines
425 B

// +build linux darwin
package main
import (
"syscall"
"github.com/qiniu/log"
)
func init() {
go reapChildren()
}
func reapChildren() {
var wstatus syscall.WaitStatus
for {
pid, err := syscall.Wait4(-1, &wstatus, 0, nil)
for err == syscall.EINTR {
pid, err = syscall.Wait4(-1, &wstatus, 0, nil)
}
if err == syscall.ECHILD {
break
}
log.Printf("pid %d, finished, wstatus: %+v", pid, wstatus)
}
}