2014-09-04 05:29:19 +00:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package native
|
|
|
|
|
|
|
|
import (
|
2014-11-06 01:14:13 +00:00
|
|
|
"encoding/json"
|
2014-09-04 05:29:19 +00:00
|
|
|
"os"
|
2014-09-09 04:19:32 +00:00
|
|
|
|
2014-09-04 05:29:19 +00:00
|
|
|
"github.com/docker/libcontainer"
|
|
|
|
)
|
|
|
|
|
|
|
|
func findUserArgs() []string {
|
2014-09-11 00:06:59 +00:00
|
|
|
for i, a := range os.Args {
|
2014-09-04 05:29:19 +00:00
|
|
|
if a == "--" {
|
2014-09-11 00:06:59 +00:00
|
|
|
return os.Args[i+1:]
|
2014-09-04 05:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-11 00:06:59 +00:00
|
|
|
return []string{}
|
2014-09-04 05:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2014-11-06 01:14:13 +00:00
|
|
|
if err := json.NewDecoder(os.NewFile(3, "child")).Decode(&config); err != nil {
|
2014-09-04 05:29:19 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return config, nil
|
|
|
|
}
|