mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
ed556fb38f
We removed the syncpipe package and replaced it with specific calls to create a new *os.File from a specified fd passed to the process. This reduced code and an extra object to manage the container's init lifecycle. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
29 lines
563 B
Go
29 lines
563 B
Go
// +build linux
|
|
|
|
package native
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
|
|
"github.com/docker/libcontainer"
|
|
)
|
|
|
|
func findUserArgs() []string {
|
|
for i, a := range os.Args {
|
|
if a == "--" {
|
|
return os.Args[i+1:]
|
|
}
|
|
}
|
|
return []string{}
|
|
}
|
|
|
|
// loadConfigFromFd loads a container's config from the sync pipe that is provided by
|
|
// fd 3 when running a process
|
|
func loadConfigFromFd() (*libcontainer.Config, error) {
|
|
var config *libcontainer.Config
|
|
if err := json.NewDecoder(os.NewFile(3, "child")).Decode(&config); err != nil {
|
|
return nil, err
|
|
}
|
|
return config, nil
|
|
}
|