mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
internal/systemd: simplify
Remove unused code and argument from the ActivationFiles, and simplify its usage. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
+2
-13
@@ -33,22 +33,11 @@ const (
|
|||||||
listenFdsStart = 3
|
listenFdsStart = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// Files returns a slice containing a `os.File` object for each
|
// Files returns a slice containing a os.File object for each
|
||||||
// file descriptor passed to this process via systemd fd-passing protocol.
|
// file descriptor passed to this process via systemd fd-passing protocol.
|
||||||
//
|
//
|
||||||
// The order of the file descriptors is preserved in the returned slice.
|
// The order of the file descriptors is preserved in the returned slice.
|
||||||
// `unsetEnv` is typically set to `true` in order to avoid clashes in
|
func Files() []*os.File {
|
||||||
// fd usage and to avoid leaking environment flags to child processes.
|
|
||||||
func Files(unsetEnv bool) []*os.File {
|
|
||||||
if unsetEnv {
|
|
||||||
defer func() {
|
|
||||||
// Unsetenv implementation for unix never returns an error.
|
|
||||||
_ = os.Unsetenv("LISTEN_PID")
|
|
||||||
_ = os.Unsetenv("LISTEN_FDS")
|
|
||||||
_ = os.Unsetenv("LISTEN_FDNAMES")
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
pid, err := strconv.Atoi(os.Getenv("LISTEN_PID"))
|
pid, err := strconv.Atoi(os.Getenv("LISTEN_PID"))
|
||||||
if err != nil || pid != os.Getpid() {
|
if err != nil || pid != os.Getpid() {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
+1
-7
@@ -399,17 +399,11 @@ func startContainer(context *cli.Context, action CtAct, criuOpts *libcontainer.C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support on-demand socket activation by passing file descriptors into the container init process.
|
|
||||||
listenFDs := []*os.File{}
|
|
||||||
if os.Getenv("LISTEN_FDS") != "" {
|
|
||||||
listenFDs = activation.Files(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
r := &runner{
|
r := &runner{
|
||||||
enableSubreaper: !context.Bool("no-subreaper"),
|
enableSubreaper: !context.Bool("no-subreaper"),
|
||||||
shouldDestroy: !context.Bool("keep"),
|
shouldDestroy: !context.Bool("keep"),
|
||||||
container: container,
|
container: container,
|
||||||
listenFDs: listenFDs,
|
listenFDs: activation.Files(), // On-demand socket activation.
|
||||||
notifySocket: notifySocket,
|
notifySocket: notifySocket,
|
||||||
consoleSocket: context.String("console-socket"),
|
consoleSocket: context.String("console-socket"),
|
||||||
pidfdSocket: context.String("pidfd-socket"),
|
pidfdSocket: context.String("pidfd-socket"),
|
||||||
|
|||||||
Reference in New Issue
Block a user