process

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 10 Imported by: 0

README

process

Go Reference go.mod Go version

process is a Go package that provides utilities for looking up operating system process IDs (PIDs) and metadata.

It supports the following platforms:

  • Darwin (macOS) – requires cgo
  • Windows
  • Linux

Installation and docs

Install using:

go get github.com/irbis-sh/process

Full package documentation is available at https://pkg.go.dev/github.com/irbis-sh/process.

Contributions

Contributions – including bug reports and pull requests – are welcome.

If you'd like to contribute directly to the codebase, please first open an issue outlining the intended bug fix or feature and the approach you plan to take.

Documentation

Overview

Package process provides access to operating system process information.

It defines PID, a process identifier with methods for retrieving process metadata, and functions for locating processes by network port.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when no matching process is found.
	ErrNotFound = errors.New("process not found")
)

Functions

This section is empty.

Types

type PID

type PID int

PID identifies an operating system process.

func FindPIDByRequest added in v0.3.0

func FindPIDByRequest(r *http.Request) (PID, error)

FindPIDByRequest returns the PID that owns the TCP/IPv4 source port for r.

Only works for local requests. Returns ErrNotFound if no process owns the port.

func FindPIDBySourcePort

func FindPIDBySourcePort(port uint16) (PID, error)

FindPIDBySourcePort returns the PID that owns the given TCP/IPv4 source port. It returns ErrNotFound if no process owns the port.

func (PID) ExecutablePath

func (pid PID) ExecutablePath() (string, error)

ExecutablePath returns the filesystem path to the process executable.

func (PID) Name

func (pid PID) Name() (string, error)

Name returns a best-effort display name for the process.

Its meaning is operating system dependent. The returned name may come from process metadata rather than the executable filename, may be truncated, and is not guaranteed to be stable over the lifetime of the process.

Name is intended for display and diagnostics. Callers that need a stable identifier should use PID or ExecutablePath instead.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL