proc

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package proc holds small filesystem/process helpers shared by the start and stop commands: reading a PID file, liveness probing, and waiting for exit.

Liveness (Alive) and graceful stop (Terminate) are split across build tags — proc_unix.go uses signal semantics (signal 0 to probe, SIGTERM to stop), proc_windows.go uses the Win32 process API (OpenProcess/exit-code probe, TerminateProcess) — because os.Process.Signal on native Windows supports ONLY Kill and rejects both signal-0 and SIGTERM (OPS-20). Without the split, a local (non-Docker) install on Windows would see a live app reported as dead (Alive→false clears the PID file) or a failed SIGTERM out of `jenticctl stop`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alive

func Alive(proc *os.Process) bool

Alive reports whether the process is currently running. The probe is platform-specific (see aliveImpl in proc_unix.go / proc_windows.go): a signal-0 send on Unix, an OpenProcess + exit-code check on Windows.

func FileExists

func FileExists(path string) bool

FileExists reports whether path exists and is a regular file.

func LivePID

func LivePID(path string) (pid int, alive bool, err error)

LivePID reads the PID file at path and reports the recorded process id and whether that process is currently running. A missing PID file yields (0, false, nil); only a malformed/unreadable file returns an error. A present file whose process has exited yields (pid, false, nil) — a stale PID file.

func ReadPIDFile

func ReadPIDFile(path string) (int, error)

ReadPIDFile reads and parses the PID stored at path.

func Terminate added in v0.32.0

func Terminate(proc *os.Process) error

Terminate requests a graceful stop of the process, returning any error from the platform stop primitive. On Unix it sends SIGTERM (the process can run its shutdown handlers); on Windows — where os.Process.Signal accepts only Kill — it falls back to a hard TerminateProcess via p.Kill(), since there is no portable graceful-signal equivalent (OPS-20). Callers still escalate to Kill after a timeout via the existing stop flow.

func WaitForExit

func WaitForExit(proc *os.Process, timeout time.Duration) bool

WaitForExit polls until the process exits or timeout elapses, returning true if it exited.

Types

This section is empty.

Jump to

Keyboard shortcuts

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