pidfile

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pidfile records a process id in a file, for a service manager or a command line that signals the process later.

Index

Constants

View Source
const Mode = 0o644

Mode is the mode a pidfile is created with, before the umask.

Variables

This section is empty.

Functions

func Read

func Read(path string) (int, error)

Read returns the process id recorded in the file at path.

Types

type Pidfile

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

Pidfile is the file a process records its own id in.

The zero value is disabled, which is what an empty path asks for, and every method on it is then a no-op. A pidfile is a record and not a lock: Write overwrites whatever was there, and Remove gives the file up only while it still holds the id Write put in it.

func New

func New(path string) Pidfile

New returns the pidfile at path, disabled when path is empty.

func (*Pidfile) Remove

func (f *Pidfile) Remove() error

Remove deletes the file, unless another process has since claimed it.

func (*Pidfile) Write

func (f *Pidfile) Write() error

Write records this process's id, overwriting a file left by a dead one.

Jump to

Keyboard shortcuts

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