mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
sd-notify: do not hang when NOTIFY_SOCKET is used with create
if NOTIFY_SOCKET is used, do not block the main runc process waiting for events on the notify socket. Bind mount the parent directory of the notify socket, so that "start" can create the socket and it is still accessible from the container. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer"
|
||||
"github.com/urfave/cli"
|
||||
@@ -31,7 +32,17 @@ your host.`,
|
||||
}
|
||||
switch status {
|
||||
case libcontainer.Created:
|
||||
return container.Exec()
|
||||
notifySocket, err := notifySocketStart(context, os.Getenv("NOTIFY_SOCKET"), container.ID())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Exec(); err != nil {
|
||||
return err
|
||||
}
|
||||
if notifySocket != nil {
|
||||
return notifySocket.waitForContainer(container)
|
||||
}
|
||||
return nil
|
||||
case libcontainer.Stopped:
|
||||
return errors.New("cannot start a container that has stopped")
|
||||
case libcontainer.Running:
|
||||
|
||||
Reference in New Issue
Block a user