func runInit()

in pkg/pid1/pid1.go [50:76]


func runInit(firstborn int) (int, error) {
	sigs := make(chan os.Signal, 8)
	signal.Notify(sigs)
	for sig := range sigs {
		if sig != syscall.SIGCHLD {
			// Pass it on to the real process.
			if err := syscall.Kill(firstborn, sig.(syscall.Signal)); err != nil {
				return 0, err
			}
		}
		// Always try to reap a child - empirically, sometimes this gets missed.
		die, status, err := sigchld(firstborn)
		if err != nil {
			return 0, err
		}
		if die {
			if status.Signaled() {
				return 128 + int(status.Signal()), nil
			}
			if status.Exited() {
				return status.ExitStatus(), nil
			}
			return 0, fmt.Errorf("unhandled exit status: 0x%x\n", status)
		}
	}
	return 0, fmt.Errorf("signal handler terminated unexpectedly")
}