提交 a6e7b826 编写于 作者: S Shirou WAKAYAMA

implements process.exe on linux.

上级 51c2995c
......@@ -80,7 +80,7 @@ Current Status
- create_time (linux)
- status (linux)
- cwd (linux)
- exe (freebsd)
- exe (linux, freebsd)
- uids (linux)
- gids (linux)
- terminal (linux)
......
......@@ -37,7 +37,7 @@ func NewProcess(pid int32) (*Process, error) {
// Fill Process information from fillFuncs
var wg sync.WaitGroup
funcs := []fillFunc{fillFromStat, fillFromStatus, fillFromfd,
fillFromCmdline, fillFromStatm, fillFromCwd}
fillFromCmdline, fillFromStatm, fillFromCwd, fillFromExe}
wg.Add(len(funcs))
for _, f := range funcs {
......@@ -89,6 +89,18 @@ func fillFromCwd(pid int32, p *Process) error {
return nil
}
// Get exe from /proc/(pid)/exe
func fillFromExe(pid int32, p *Process) error {
exePath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "exe")
exe, err := os.Readlink(exePath)
if err != nil {
return err
}
p.Exe = string(exe)
return nil
}
// Get cmdline from /proc/(pid)/cmdline
func fillFromCmdline(pid int32, p *Process) error {
cmdPath := filepath.Join("/", "proc", strconv.Itoa(int(pid)), "cmdline")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册