getChildPid receives the final child's pid over the provided pipe.
()
| 634 | |
| 635 | // getChildPid receives the final child's pid over the provided pipe. |
| 636 | func (p *initProcess) getChildPid() (int, error) { |
| 637 | var pid pid |
| 638 | if err := json.NewDecoder(p.comm.initSockParent).Decode(&pid); err != nil { |
| 639 | _ = p.cmd.Wait() |
| 640 | return -1, err |
| 641 | } |
| 642 | |
| 643 | // Clean up the zombie parent process |
| 644 | // On Unix systems FindProcess always succeeds. |
| 645 | firstChildProcess, _ := os.FindProcess(pid.PidFirstChild) |
| 646 | |
| 647 | // Ignore the error in case the child has already been reaped for any reason |
| 648 | _, _ = firstChildProcess.Wait() |
| 649 | |
| 650 | return pid.Pid, nil |
| 651 | } |
| 652 | |
| 653 | func (p *initProcess) waitForChildExit(childPid int) error { |
| 654 | status, err := p.cmd.Process.Wait() |