Skip to content

Release Notes v0.6.0

Released: 2026-10-08

Highlights

Process liveness, start time, and exec, so callers can tell whether a PID still belongs to the process a record was written for, and hand the terminal to another program on Unix and Windows.

New Features

process.Exists and process.StartTime

Problem solved: a file that records a PID, such as a lock file or a session record, goes stale when the process dies. The system can then hand the same PID to an unrelated process, so "does this PID exist?" gives a wrong answer.

Solution: compare the process's start time with the recorded one.

import "github.com/grokify/oscompat/process"

started, err := process.StartTime(rec.PID)
if errors.Is(err, process.ErrNotFound) {
    // the process is gone
}
if err == nil && started.Sub(rec.StartedAt).Abs() > 2*time.Second {
    // the PID was reused by a different process
}
Function Behavior
Exists(pid) Reports whether the process is running. A process owned by another user counts as running
StartTime(pid) Returns the start time, or ErrNotFound

On Unix the start time comes from ps and has one-second resolution, so allow a small tolerance when comparing. On Windows it is the process creation time, read with GetProcessTimes, using only the standard library. PIDs of zero or less are rejected, because on Unix they address process groups.

process.Exec

Problem solved: a launcher that wants to hand the terminal to another program, such as an editor or an agent CLI, wants the program to replace it. Windows cannot replace a running process.

Solution:

err := process.Exec(path, []string{"claude", "--resume", id})
// Unix: replaces this process. Windows: runs a child with the terminal
// attached and exits with its status. Returns only on failure.

Installation

go get github.com/grokify/oscompat@v0.6.0

Compatibility

No breaking changes. The module still has no dependencies outside the standard library.