notifyHost tells the host (usually systemd) that the container reported READY. Also sends MAINPID and BARRIER.
(client *net.UnixConn, ready []byte, pid1 int)
| 154 | // notifyHost tells the host (usually systemd) that the container reported READY. |
| 155 | // Also sends MAINPID and BARRIER. |
| 156 | func notifyHost(client *net.UnixConn, ready []byte, pid1 int) error { |
| 157 | _, err := client.Write(append(ready, '\n')) |
| 158 | if err != nil { |
| 159 | return err |
| 160 | } |
| 161 | |
| 162 | // now we can inform systemd to use pid1 as the pid to monitor |
| 163 | newPid := "MAINPID=" + strconv.Itoa(pid1) |
| 164 | _, err = client.Write([]byte(newPid + "\n")) |
| 165 | if err != nil { |
| 166 | return err |
| 167 | } |
| 168 | |
| 169 | // wait for systemd to acknowledge the communication |
| 170 | return sdNotifyBarrier(client) |
| 171 | } |
| 172 | |
| 173 | // errUnexpectedRead is reported when actual data was read from the pipe used |
| 174 | // to synchronize with systemd. Usually, that pipe is only closed. |
searching dependent graphs…