gastownhall/beads · error

empty executable basename for pid %d

Error message

empty executable basename for pid %d

What it means

On macOS, processExecutableBasename resolves a pid's executable via a command (ps-style lookup) and takes its basename. If the trimmed output is '.', the path separator, or empty, the resolved name is unusable, so the library returns this error rather than comparing against a garbage executable name.

Source

Thrown at internal/storage/dbproxy/proxy/process_executable_darwin.go:27

	"path/filepath"
	"strconv"
	"strings"
	"syscall"

	"golang.org/x/sys/unix"
)

func processExecutableBasename(pid int) (basename string, gone bool, err error) {
	output, commandErr := exec.Command("ps", "-p", strconv.Itoa(pid), "-o", "comm=").Output()
	if commandErr != nil {
		if killErr := syscall.Kill(pid, 0); errors.Is(killErr, unix.ESRCH) {
			return "", true, nil
		}
		return "", false, commandErr
	}
	base := filepath.Base(strings.TrimSpace(string(output)))
	if base == "." || base == string(filepath.Separator) || base == "" {
		return "", false, fmt.Errorf("empty executable basename for pid %d", pid)
	}
	return base, false, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Retry the lookup; the pid may have been in transient state
  2. Verify the pid is alive before verification (e.g. signal 0 check)
  3. Fall back to a different executable-resolution method or skip verification for that pid
Defensive patterns

Strategy: retry

Validate before calling

if !pidAlive(pid) { return fmt.Errorf("pid %d not running", pid) }

Type guard

func validBasename(b string) bool { return b != "" && b != "." && b != "/" }

Try / catch

base, exited, err := processExecutableBasename(pid)
if err != nil { /* treat as unverified or retry */ }

Prevention

When it happens

Trigger: Calling processExecutableBasename on darwin for a pid whose executable path resolves to an empty/invalid basename — typically a just-exited or reaped process whose command output is empty.

Common situations: Pid exited between lookup and verification; zombie process with no command; pid recycled to a kernel process with odd metadata.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/e8ef6659d85e7531. Report an issue: GitHub.