lockfile

package
v0.0.0-...-994b3fd Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package lockfile provides directory-based locking to prevent multiple PromptPipe instances.

This package implements a robust file locking mechanism using syscall-level locks that are automatically released when the process exits (gracefully or not).

Index

Constants

View Source
const LockFileName = "promptpipe.lock"

LockFileName is the name of the lock file created in the state directory

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

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

Lock represents an active directory lock

func AcquireLock

func AcquireLock(stateDir string) (*Lock, error)

AcquireLock attempts to acquire an exclusive lock on the state directory. Returns a Lock instance if successful, or an error with detailed information about the conflicting process if the lock is already held.

func (*Lock) Release

func (l *Lock) Release() error

Release releases the lock and removes the lock file. This method is safe to call multiple times.

type LockError

type LockError struct {
	LockPath     string
	ExistingInfo string
	Cause        error
}

LockError represents an error when failing to acquire a lock due to another process

func (*LockError) Error

func (e *LockError) Error() string

func (*LockError) Unwrap

func (e *LockError) Unwrap() error

Jump to

Keyboard shortcuts

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