Skip to content

flaky: desktop-linux teardown asserts pid gone before the zombie is reaped #79

Closed

Description

@ElbertePlinio

What happened

Main run 33794016944 for ea42c24 (#78, Rust and docs only) failed one test:

packages/desktop-linux/test/integration.test.ts
  desktop integration (Xvfb + xdotool) > runs an xvfb session and screenshots the display
  AssertionError: expected true to be false   (integration.test.ts:552)

The same test passed on #78's own PR run minutes earlier and on the previous five main runs.

Cause

Line 552 asserts isPidAlive(session.xvfbPid) is false right after destroyDesktopSession returns.

  • destroyDesktopSession stops Xvfb through stopProcessGroupVerified in packages/core/src/proc.ts, which returns terminated when the group is empty and the leader is gone or is a zombie (state === "Z"). That is deliberate: the child is reaped asynchronously by whoever spawned it.
  • isPidAlive is process.kill(pid, 0), which succeeds for a zombie. So there is a window between "verified terminated" and "reaped" where the assertion sees true.

The teardown is correct. The assertion measures a different thing than the teardown guarantees.

Fix options

  • In the test, poll isPidAlive for a short deadline instead of asserting once, or assert on /proc/<pid>/stat not being a live (non-Z) process, matching what stopProcessGroupVerified verifies.
  • Or have destroyDesktopSession wait for the spawned child's exit event when it owns the handle, so the pid is reaped before it returns. Larger change, and it only helps when the destroyer is also the spawner.

The first option is a test-only change and is the one I would take.

Activity

  1. added
    bug
    on Sep 3, 2026
  2. added a commit that references this issue on Sep 4, 2026
    3ad282c
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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions