Documentation
¶
Index ¶
- func DetachProcess(cmd *exec.Cmd)
- func HideWindow(_ *exec.Cmd)
- func LockFile(f *os.File) error
- func LooksAbsolutePath(path string) bool
- func NormalizePathForCompare(p string) string
- func ReplaceFile(src, dst string) error
- func SafeRename(src, dst string) error
- func SetProcessGroup(cmd *exec.Cmd)
- func TermSignals() []os.Signal
- func TryLockFile(f *os.File) (bool, error)
- func UnlockFile(f *os.File) error
- func UpdateFileLocked(ctx context.Context, path string, defaultMode os.FileMode, ...) error
- func WithFileLock(ctx context.Context, path string, fn func() error) error
- func WithoutLoopbackProxies(env []string) []string
- func WriteFileAtomic(path string, data []byte, defaultMode os.FileMode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetachProcess ¶
DetachProcess configures cmd to run in a new session, detached from the parent. The child survives the parent exiting.
func HideWindow ¶ added in v0.3.2
HideWindow is a no-op on Unix. On Windows it suppresses console window creation for subprocess invocations from detached workers.
func LooksAbsolutePath ¶
LooksAbsolutePath returns true if path looks like an absolute path on any OS. Unlike filepath.IsAbs, this recognizes POSIX-style absolute paths (/workspace/...) even on Windows, which is needed for file paths from agent payloads that may use POSIX conventions regardless of host OS.
func NormalizePathForCompare ¶ added in v0.3.2
NormalizePathForCompare returns a path suitable for case-aware prefix matching. On Windows, paths are lowercased because the filesystem is case-insensitive (C:\Users and c:\Users are the same path). On macOS/Linux, the path is returned unchanged.
func ReplaceFile ¶ added in v0.6.0
ReplaceFile replaces dst without removing it first, avoiding a missing-destination window. On Windows it uses MoveFileEx with replace-existing and write-through flags and retries transient file access errors. Use it when dst must remain present during replacement.
func SafeRename ¶
SafeRename moves src to dst, replacing dst if it exists. On Windows, it removes dst first because os.Rename cannot overwrite an existing file. It retries transient sharing, lock, and access errors caused by concurrent readers or writers. This is not atomic on Windows.
func SetProcessGroup ¶
SetProcessGroup configures cmd to run in a new process group.
func TermSignals ¶
TermSignals returns the signals to listen for graceful shutdown.
func TryLockFile ¶ added in v0.6.0
TryLockFile attempts to acquire an exclusive lock without blocking. Returns false when another holder has the lock.
func UpdateFileLocked ¶ added in v0.6.1
func UpdateFileLocked(ctx context.Context, path string, defaultMode os.FileMode, merge func(current []byte) ([]byte, error)) error
UpdateFileLocked serializes an atomic read-modify-write. merge receives nil for a missing file; returning nil leaves the destination unchanged.
func WithFileLock ¶ added in v0.6.1
WithFileLock runs fn under a process-shared lock associated with path. Waiting for the lock honors ctx.
func WithoutLoopbackProxies ¶ added in v0.3.5
WithoutLoopbackProxies returns a copy of env with any proxy variable whose value points at a literal loopback host removed. Other entries are preserved in their original order.
This drops short-lived localhost proxies inherited from the parent process while keeping real forward proxies in place.
Loopback recognition is syntactic only - no DNS resolution is performed, keeping the function deterministic and side-effect free on the spawn path. A host is treated as loopback when it is exactly "localhost" or when it parses as an IP inside 127.0.0.0/8 or equal to "::1". Scheme-less values like "127.0.0.1:64788" are parsed as if they had an "http://" prefix for inspection only.
Types ¶
This section is empty.