pidpath

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package p1idpath is a helper for managing a PID file to denote when a process might already be running.

Index

Constants

View Source
const UnknownPID = -1

UnknownPID indicates the PID read from the file wasn't located as a running process.

Variables

This section is empty.

Functions

This section is empty.

Types

type PidPath

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

PidPath is the type for managing a PID file.

func NewPidPath

func NewPidPath(pathname string, perm fs.FileMode) *PidPath

NewPidPath manages a process ID file to coordinate whether a process is already running.

func (*PidPath) Check

func (pp *PidPath) Check() error

Check will determine the state of the process. A `nil` returned indicates no other process was found active.

func (*PidPath) CheckAndSet

func (pp *PidPath) CheckAndSet() error

CheckAndSet evaluates if the process is currently running and, if not, sets the current process ID into the file.

func (*PidPath) Getpid

func (pp *PidPath) Getpid() int

Getpid retrieves the process ID from the file.

func (*PidPath) IsOurs

func (pp *PidPath) IsOurs() bool

IsOurs determines if the pidpath indicates that its process is the currently executing one (the caller) of this function.

func (*PidPath) IsRunning

func (pp *PidPath) IsRunning() bool

IsRunning determines if the pidpath indicates that its process is in the process listing (see Getpid's note).

func (*PidPath) Release

func (pp *PidPath) Release() error

Release will remove the pidpath if it's owned by the current process (i.e. this is safe to call if the pidpath is being managed by another process--the file will NOT be removed).

func (*PidPath) String

func (pp *PidPath) String() string

String provides the path and other PID info.

Jump to

Keyboard shortcuts

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