Skip to content

Linux: device claim owner identity uses ps -o lstart, which shifts when the clock is stepped (WSL2), so a session gets DEVICE_IN_USE on its own claim #4437

Closed

Description

@matheustimbo

Version: agent-device 0.21.36 (also on main: packages/host-kit/src/internal/host-process.ts, readProcessStartTime and the pid=,state=,lstart= batch probe).
Host: WSL2 (Ubuntu 24.04, kernel 6.18.58.1-microsoft-standard-WSL2), daemon started by a Simlock worker.

What happens

install on a device the session just opened fails:

Error (DEVICE_IN_USE): android device emulator-5588 is owned by session "<same session>" in workspace "/home/<user>".

The diagnostics log shows phase: device_claim_conflict, classification: owner-process-reused, and the owner session is the caller's own.

Why

The claim stores ownerStartTime from ps -p <pid> -o lstart=. lstart is derived from boot time plus the process start in ticks, and Linux recomputes boot time when the wall clock is stepped. WSL2 steps the clock regularly to follow the Windows host, so the same live process reports a different lstart minutes later. Measured on one daemon process:

When lstart for the same PID
claim written Mon Nov 9 23:54:54 2026
first install Mon Nov 9 23:54:57 2026
a few minutes later Mon Nov 9 23:54:58 2026

The exact string comparison then classifies the live owner as a reused PID and refuses the command.

Suggested fix

On Linux, read the start time from /proc/<pid>/stat field 22 (starttime, clock ticks since boot), optionally paired with /proc/sys/kernel/random/boot_id to survive reboots. That value does not move when the clock is stepped. Keep ps -o lstart for macOS. A tolerance window on lstart would also work, but it weakens the PID-reuse check.

Workaround we verified

Patching the three lstart= reads in dist/src/sdk-io.js to return linux:<boot_id>:<starttime> from /proc and restarting the daemon makes install succeed on a fresh lease, and the claim records ownerStartTime: "linux:<boot_id>:5371442".

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions