From b1247d2d0d51108c910a73891ff3116e5f032ab1 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Sat, 12 Jan 2019 18:39:45 +0100 Subject: [pkg] all your deps are vendored to us --- vendor/github.com/mitchellh/go-ps/process_linux.go | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 vendor/github.com/mitchellh/go-ps/process_linux.go (limited to 'vendor/github.com/mitchellh/go-ps/process_linux.go') diff --git a/vendor/github.com/mitchellh/go-ps/process_linux.go b/vendor/github.com/mitchellh/go-ps/process_linux.go new file mode 100644 index 0000000..c1558f7 --- /dev/null +++ b/vendor/github.com/mitchellh/go-ps/process_linux.go @@ -0,0 +1,35 @@ +// +build linux + +package ps + +import ( + "fmt" + "io/ioutil" + "strings" +) + +// Refresh reloads all the data associated with this process. +func (p *UnixProcess) Refresh() error { + statPath := fmt.Sprintf("/proc/%d/stat", p.pid) + dataBytes, err := ioutil.ReadFile(statPath) + if err != nil { + return err + } + + // First, parse out the image name + data := string(dataBytes) + binStart := strings.IndexRune(data, '(') + 1 + binEnd := strings.IndexRune(data[binStart:], ')') + p.binary = data[binStart : binStart+binEnd] + + // Move past the image name and start parsing the rest + data = data[binStart+binEnd+2:] + _, err = fmt.Sscanf(data, + "%c %d %d %d", + &p.state, + &p.ppid, + &p.pgrp, + &p.sid) + + return err +} -- cgit v1.2.3