package pidfile

import "github.com/docker/docker/pkg/pidfile"

Package pidfile provides structure and helper functions to create and remove PID file. A PID file is usually a file used to store the process ID of a running process.

Index

Functions

func Read

func Read(path string) (pid int, err error)

Read reads the "PID file" at path, and returns the PID if it contains a valid PID of a running process, or 0 otherwise. It returns an error when failing to read the file, or if the file doesn't exist, but malformed content is ignored. Consumers should therefore check if the returned PID is a non-zero value before use.

func Write

func Write(path string, pid int) error

Write writes a "PID file" at the specified path. It returns an error if the file exists and contains a valid PID of a running process, or when failing to write the file.

Source Files

pidfile.go

Version
v24.0.1+incompatible
Published
May 19, 2023
Platform
js/wasm
Imports
5 packages
Last checked
18 minutes ago

Tools for package owners.