github.com/fcwu/docker@v1.4.2-0.20150115145920-2a69ca89f0df/daemon/execdriver/native/utils.go (about)

     1  // +build linux
     2  
     3  package native
     4  
     5  import (
     6  	"encoding/json"
     7  	"os"
     8  
     9  	"github.com/docker/libcontainer"
    10  )
    11  
    12  func findUserArgs() []string {
    13  	for i, a := range os.Args {
    14  		if a == "--" {
    15  			return os.Args[i+1:]
    16  		}
    17  	}
    18  	return []string{}
    19  }
    20  
    21  // loadConfigFromFd loads a container's config from the sync pipe that is provided by
    22  // fd 3 when running a process
    23  func loadConfigFromFd() (*libcontainer.Config, error) {
    24  	var config *libcontainer.Config
    25  	if err := json.NewDecoder(os.NewFile(3, "child")).Decode(&config); err != nil {
    26  		return nil, err
    27  	}
    28  	return config, nil
    29  }