I have some go code like this:
cmd = exec.Command(command)
//...
cmd.Run()
func reapChild(cmd) {
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGCHLD)
go func() {
my_signal := <- sigc
log.Infof("appstore: reapChildren: got a SIGCHLD signal")
cmd.Wait()
signal.Stop(sigc)
}()
}
This reaps the process for a specific spawned child, but I'm looking for something more generic.
Is there a way to get the PID off my_signal? I'm looking for something like the pid_t wait(int *status) -- golang provides a function called Wait4 that takes a specific PID.