Help us shape the future of Go! Take the 2026 Go Developer Survey

pidfile

package
v5.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

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

This is a temporary copy of github.com/moby/moby/v2/pkg/pidfile, and should be replaced once pidfile is available as a standalone module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(path string) (pid int, _ 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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