| 125 | } |
| 126 | |
| 127 | func waitForCommand(desc string, pid int) error { |
| 128 | process, err := os.FindProcess(pid) |
| 129 | if err != nil { |
| 130 | return fmt.Errorf("failed to look up process for lifecycle command %q: %v", desc, err) |
| 131 | } |
| 132 | status, err := process.Wait() |
| 133 | if err != nil { |
| 134 | return fmt.Errorf("failed to wait for lifecycle command %q: %v", desc, err) |
| 135 | } |
| 136 | if exitCode := status.ExitCode(); exitCode != 0 { |
| 137 | return fmt.Errorf("lifecycle command %q failed with status %d", desc, exitCode) |
| 138 | } |
| 139 | return nil |
| 140 | } |
| 141 | |
| 142 | // ScriptLines returns shell syntax for executing the commands in the |
| 143 | // LifecycleScript. |