Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
| ... | ... |
@@ -50,6 +50,7 @@ type remote struct {
|
| 50 | 50 |
eventTsPath string |
| 51 | 51 |
pastEvents map[string]*containerd.Event |
| 52 | 52 |
runtimeArgs []string |
| 53 |
+ daemonWaitCh chan struct{}
|
|
| 53 | 54 |
} |
| 54 | 55 |
|
| 55 | 56 |
// New creates a fresh instance of libcontainerd remote. |
| ... | ... |
@@ -129,6 +130,7 @@ func (r *remote) handleConnectionChange() {
|
| 129 | 129 |
transientFailureCount = 0 |
| 130 | 130 |
if utils.IsProcessAlive(r.daemonPid) {
|
| 131 | 131 |
utils.KillProcess(r.daemonPid) |
| 132 |
+ <-r.daemonWaitCh |
|
| 132 | 133 |
} |
| 133 | 134 |
if err := r.runContainerdDaemon(); err != nil { //FIXME: Handle error
|
| 134 | 135 |
logrus.Errorf("error restarting containerd: %v", err)
|
| ... | ... |
@@ -388,7 +390,11 @@ func (r *remote) runContainerdDaemon() error {
|
| 388 | 388 |
return err |
| 389 | 389 |
} |
| 390 | 390 |
|
| 391 |
- go cmd.Wait() // Reap our child when needed |
|
| 391 |
+ r.daemonWaitCh = make(chan struct{})
|
|
| 392 |
+ go func() {
|
|
| 393 |
+ cmd.Wait() |
|
| 394 |
+ close(r.daemonWaitCh) |
|
| 395 |
+ }() // Reap our child when needed |
|
| 392 | 396 |
r.daemonPid = cmd.Process.Pid |
| 393 | 397 |
return nil |
| 394 | 398 |
} |