github.com/windmilleng/containerd@v0.2.7/runtime/process_linux.go (about)

     1  // +build linux
     2  
     3  package runtime
     4  
     5  import (
     6  	"io/ioutil"
     7  	"path/filepath"
     8  	"strconv"
     9  )
    10  
    11  func (p *process) getPidFromFile() (int, error) {
    12  	data, err := ioutil.ReadFile(filepath.Join(p.root, "pid"))
    13  	if err != nil {
    14  		return -1, err
    15  	}
    16  	i, err := strconv.Atoi(string(data))
    17  	if err != nil {
    18  		return -1, errInvalidPidInt
    19  	}
    20  	p.pid = i
    21  	return i, nil
    22  }