mitchellh / go-ps

Find, list, and inspect processes from Go (golang).
https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc
MIT License
1.47k stars 251 forks source link

Executable() in ps.Processes does not return the full process name #2

Open miroswan opened 9 years ago

miroswan commented 9 years ago

Code

package main

import (
    "fmt"
    "log"
     ps "github.com/mitchellh/go-ps"
)

func main() {

    if p, err := ps.Processes(); err != nil {
        log.Fatal(err)
    } else {
        for _, v := range p {
            fmt.Println(v.Executable())
        }
    }
}

Example Truncated process: NetworkBrowserAg

Is this a limitation of the system call sysctl or the implementation of the darwinProcesses() C function? It would be nice to have the full process name in order to instill confidence when selecting processes by name.

This tool will be largely helpful for systems /(administrators|engineers)/ who want to move to Go from the standard interpreted variety (which is great because packaging and deploying is easier). If the full process name is available, I wager that go-ps would be a bit more practical! What do you think?

vtolstov commented 8 years ago

please check pr #6

SimonSchick commented 8 years ago

I have the same problem as well, any chance #6 will actually get merged? @mitchellh

gabriel commented 8 years ago

In this fork, https://github.com/keybase/go-ps, I added a Path() method to Process which returns the full path to executable.

Supported on windows and darwin. (Uses the yeonsh patch for darwin.)

SimonSchick commented 8 years ago

That looks useful, ty.