daemonlifecycle

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package daemonlifecycle provides the small cross-platform primitives shared by CLI daemons: owner-only state paths and advisory file locking.

It deliberately does not own a daemon's state machine, process launching, or recovery policy. Those remain product decisions. This package only keeps the security- and OS-sensitive mechanics identical across CLI implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lock

func Lock(ctx context.Context, file *os.File, interval time.Duration) error

Lock waits for an exclusive advisory lock, polling at interval until ctx is cancelled. A non-positive interval uses 25 milliseconds.

func ProtectOwnerOnly

func ProtectOwnerOnly(path string) error

ProtectOwnerOnly replaces path's access policy with one granting access only to the current user. Directories keep inheritable permissions for children.

func ProtectOwnerOnlyFile

func ProtectOwnerOnlyFile(file *os.File) error

ProtectOwnerOnlyFile replaces an already-open file's access policy with one granting access only to the current user. Consumers must subsequently call ValidateOwnerOnlyFile before trusting the handle. On Windows, applying the policy uses the file name because ordinary os.OpenFile handles do not carry WRITE_DAC; the handle-based validation detects any path replacement.

func TryLock

func TryLock(file *os.File) (bool, error)

TryLock obtains an exclusive non-blocking advisory lock on file.

func Unlock

func Unlock(file *os.File) error

Unlock releases a lock obtained with TryLock or Lock.

func ValidateOwnerOnly

func ValidateOwnerOnly(path string) error

ValidateOwnerOnly verifies that path is a regular file or directory whose effective access policy grants access only to the current user.

func ValidateOwnerOnlyFile

func ValidateOwnerOnlyFile(file *os.File) error

ValidateOwnerOnlyFile verifies the effective policy of an already-open regular file. Consumers that make security decisions after opening a lock or state file should prefer this handle-based form.

Types

This section is empty.

Jump to

Keyboard shortcuts

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