proc

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: GPL-3.0, LGPL-3.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package proc contains utilities for checking processes via /proc.

Index

Constants

This section is empty.

Variables

View Source
var ErrUserBusy = errors.New("user is currently used by process")

ErrUserBusy is returned by CheckUserBusy if the user is currently used by a process.

Functions

func CheckUserBusy

func CheckUserBusy(name string, uid uint32) error

CheckUserBusy checks if a user is currently running any processes.

It is a re-implementation of this user_busy_processes() function: https://github.com/shadow-maint/shadow/blob/e78742e553c12222b40b13224d3b0fafaceae791/lib/user_busy.c#L164-L272

It returns ErrUserBusy if the user has active processes, nil otherwise.

Types

type Process added in v0.7.2

type Process struct {
	// contains filtered or unexported fields
}

Process holds a kernel reference to one process, independent of PID reuse.

func OpenProcess added in v0.7.2

func OpenProcess(pid int) (*Process, error)

OpenProcess opens a pidfd for a local process. RPC callers must instead use the pidfd supplied by SO_PEERPIDFD.

func ProcessFromFile added in v0.7.2

func ProcessFromFile(file *os.File) (*Process, error)

ProcessFromFile takes ownership of a pidfd, including on error.

func (*Process) Alive added in v0.7.2

func (p *Process) Alive() (bool, error)

Alive checks the kernel reference, not the numeric PID.

func (*Process) Clone added in v0.7.2

func (p *Process) Clone() (*Process, error)

Clone opens a separate pidfd for the same live process. A separate open file description prevents systemd from deduplicating owners of different users.

func (*Process) Close added in v0.7.2

func (p *Process) Close() error

Close releases this process reference.

func (*Process) File added in v0.7.2

func (p *Process) File() *os.File

File returns the pidfd. The caller must not close it.

func (*Process) PID added in v0.7.2

func (p *Process) PID() (int, error)

PID returns the process ID, or -1 if the process has been reaped.

Jump to

Keyboard shortcuts

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