go-ps icon indicating copy to clipboard operation
go-ps copied to clipboard

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

Open miroswan opened this issue 9 years ago • 4 comments

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?

miroswan avatar May 12 '15 19:05 miroswan

please check pr #6

vtolstov avatar Dec 07 '15 21:12 vtolstov

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

SimonSchick avatar May 13 '16 21:05 SimonSchick

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.)

gabriel avatar May 14 '16 00:05 gabriel

That looks useful, ty.

SimonSchick avatar May 14 '16 00:05 SimonSchick