Skip to content

fix(update): exclude ancestor PIDs from running-process check#164

Merged
jrob5756 merged 1 commit intomainfrom
fix/update-self-detection
May 6, 2026
Merged

fix(update): exclude ancestor PIDs from running-process check#164
jrob5756 merged 1 commit intomainfrom
fix/update-self-detection

Conversation

@jrob5756
Copy link
Copy Markdown
Collaborator

@jrob5756 jrob5756 commented May 6, 2026

Problem

On Windows, conductor update reports its own launching shim as another running Conductor process:

conductor update
Checking for updates…
Warning: 1 other Conductor process is running:
  • PID 299112: conductor.exe

The shim conductor.exe is a separate process from the Python interpreter that runs this code, so os.getpid() does not match the shim's PID — the shim was incorrectly flagged.

Fix

Walk the full ancestor process chain and exclude every PID along the way:

  • Add _get_self_and_ancestor_pids() — returns {getpid(), getppid()} plus every ancestor reachable via the parent-PID map.
  • Add _build_parent_pid_map() — uses wmic on Windows and ps -axo pid=,ppid= elsewhere. Returns {} on any failure.
  • _find_running_conductor_processes() now consults the excluded set on both platforms.
  • Defensive cycle detection prevents infinite walks if the parent map is malformed.

Tests

Adds 6 new tests in TestAncestorPidExclusion:

  • self_pid is in excluded set
  • getppid() is in excluded set
  • ancestor chain via parent map is excluded
  • empty parent map falls back gracefully
  • cyclic parent map terminates the walk
  • ancestor reported by ps/tasklist is filtered out

All 68 update tests pass; lint and typecheck clean.

On Windows, 'conductor.exe' is a shim that launches python.exe to run
this code. The shim has a different PID from os.getpid(), so excluding
only self_pid caused the launching shim to be reported as 'another
running Conductor process' during 'conductor update'.

Now walk the full ancestor chain (via wmic on Windows, ps elsewhere) and
exclude every PID along the way. Falls back to {getpid(), getppid()} if
the parent map cannot be built.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jrob5756 jrob5756 merged commit f582075 into main May 6, 2026
3 checks passed
@jrob5756 jrob5756 deleted the fix/update-self-detection branch May 6, 2026 17:32
@jrob5756 jrob5756 mentioned this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant