Skip to content

fix: a zombie owner turns a successful unlock into termination_failed #59

Closed

Description

@abruption

What happened

If the signaled owner becomes a zombie (its parent does not reap it), unlock reports termination_failed with owner_did_not_exit_before_timeout and exits 3, even though the process has terminated and the lock was released.

ps -p <pid> -o lstart= still returns the original start time for a zombie, so originalProcessExited returns false for the whole polling period.

Reproduction with a fixture owner forked under a parent that does not reap (perl fork + sleep):

{"outcome":"termination_failed","processExited":false,"lockReleased":true,"transcriptUnchanged":true}

What you expected

A terminated-but-unreaped owner is recognised as exited (for example via ps -o stat= containing Z), or reported with a distinct reason such as owner_zombie, instead of a misleading timeout.

Environment

  • codex-unlock 0.4.0 at 6227e6c
  • macOS 27.0 arm64, Node.js 22.14.0

Source evidence

  • Exit decided from start time only:

    codex-unlock/src/process.ts

    Lines 167 to 173 in 6227e6c

    export function originalProcessExited(
    originalStartTime: string,
    observation: ProcessStartObservation,
    ): boolean | null {
    if (observation.status === "unknown") return null;
    return observation.status === "absent" || observation.startTime !== originalStartTime;
    }
  • Polling loop and timeout reason:

    codex-unlock/src/unlock.ts

    Lines 95 to 124 in 6227e6c

    while (Date.now() <= deadline) {
    const [startObservation, lockProbe] = await Promise.all([
    processStartTime(owner.pid),
    Promise.resolve(probeLock(inspection.lock.path)),
    ]);
    processObservation = startObservation;
    lastLockProbe = lockProbe;
    processExited = originalProcessExited(owner.startTime, startObservation);
    lockReleased = lockProbe.status === "free";
    if (processExited === true && lockReleased) {
    break;
    }
    await delay(100);
    }
    let transcriptUnchanged: boolean | null = null;
    const reasons: string[] = [];
    try {
    transcriptUnchanged = (await stableFileHash(transcriptPath)).hash === transcriptHash;
    if (!transcriptUnchanged) reasons.push("transcript_changed_during_unlock");
    } catch (error) {
    reasons.push(`post_unlock_transcript_hash_failed:${errorText(error)}`);
    }
    if (processExited === null) {
    reasons.push(
    `owner_exit_unknown:${processObservation.error ?? "process observation failed"}`,
    );
    } else if (!processExited) {
    reasons.push("owner_did_not_exit_before_timeout");
    }
  • Success requires processExited === true:
    const verified = processExited === true && lockReleased && transcriptUnchanged === true;

Acceptance criteria

  • Zombie state is detected and either treated as exited or surfaced with a dedicated reason.
  • A fixture test with an unreaped child covers the outcome and exit code.

Scope and limitations

  • Fails in the safe direction (never reports false success). Frequency is low because parents normally reap Codex processes.

Checked

Activity

  1. added
    bug
    on Sep 28, 2026
  2. added this to the v0.4.1 milestone on Sep 28, 2026
  3. added a commit that references this issue on Sep 29, 2026
    bc5c93a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions