ps – Index | Files

package ps

import ""

ps lists system processes.



var ProcFS = "/proc"

ProcFS is the path to the procfs filesystem on Linux.


type Process

type Process interface {

	Pid() int       // Process ID.
	ParentPid() int // Parent process ID.

	// Executable name running this process, i.e. "/path/to/go" or
	// "C:\path\to\go.exe".
	// This tries to get the full path name, but this may also be set to just
	// the executable name.
	Executable() string

	// Full commandline, if available.
	Commandline() []string

Process is a single process.

func Find

func Find(pid int) (Process, error)

Find looks up a single process by pid.

Returns an os.ErrNotExist error if the process isn't found.

type Processes

type Processes []Process

func List

func List() (Processes, error)

List all processes.

This is a point-in-time snapshot of when this method was called. Some operating systems don't provide snapshot capability of the process table, in which case the process table returned might contain ephemeral entities that happened to be running when this was called.

func (Processes) String

func (p Processes) String() string

type UnixProcess

type UnixProcess struct {
	// contains filtered or unexported fields

UnixProcess is an implementation of Process that contains Unix-specific fields and information.

func (*UnixProcess) Commandline

func (p *UnixProcess) Commandline() []string

func (*UnixProcess) Executable

func (p *UnixProcess) Executable() string

func (*UnixProcess) ParentPid

func (p *UnixProcess) ParentPid() int

func (*UnixProcess) Pid

func (p *UnixProcess) Pid() int

func (UnixProcess) String

func (p UnixProcess) String() string

Source Files

process.go process_linux.go

v0.0.0-20211017223000-565d098827ca (latest)
Oct 17, 2021
8 packages
Last checked
2 months ago

Tools for package owners.