Skip to content

Improve stale entry cleanup for cross-platform compatibility#38

Open
daanzu wants to merge 1 commit into
marimo-team:mainfrom
daanzu:patch-1
Open

Improve stale entry cleanup for cross-platform compatibility#38
daanzu wants to merge 1 commit into
marimo-team:mainfrom
daanzu:patch-1

Conversation

@daanzu
Copy link
Copy Markdown

@daanzu daanzu commented Apr 22, 2026

Enhanced stale entry cleanup to support both Windows and Bash process lookups.

Enhanced stale entry cleanup to support both Windows and Bash process lookups.
Copilot AI review requested due to automatic review settings April 22, 2026 08:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves stale server-registry entry cleanup in discover-servers.sh by adding Windows/MSYS/Cygwin-specific PID liveness checks so registry entries are removed correctly across mixed Windows/Bash process environments.

Changes:

  • Adds an MSYS/Cygwin branch that checks for PID existence via powershell.exe Get-Process before falling back to kill -0.
  • Keeps existing kill -0 behavior for non-Windows environments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +27 to +29
if [[ "$OSTYPE" == msys* || "$OSTYPE" == cygwin* ]]; then
if ! powershell.exe -NoProfile -Command "Get-Process -Id $pid -ErrorAction SilentlyContinue | Out-Null; if (\$?) { exit 0 } else { exit 1 }" \
&& ! kill -0 "$pid" 2>/dev/null; then
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If powershell.exe is unavailable on a given MSYS/Cygwin setup, this will emit a "command not found" error to stderr on every iteration (even though the kill -0 fallback still works). Consider checking command -v powershell.exe first (or redirecting its stderr) to keep output clean and avoid noisy logs.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Comment thread scripts/discover-servers.sh
Comment on lines +27 to +29
if [[ "$OSTYPE" == msys* || "$OSTYPE" == cygwin* ]]; then
if ! powershell.exe -NoProfile -Command "Get-Process -Id $pid -ErrorAction SilentlyContinue | Out-Null; if (\$?) { exit 0 } else { exit 1 }" \
&& ! kill -0 "$pid" 2>/dev/null; then
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$pid is interpolated directly into the PowerShell -Command string. Since the PID is read from a JSON file in the registry directory, a malformed or tampered .pid value could break the PowerShell command or be used for command injection. Please validate that pid is strictly numeric before using it, and pass it to PowerShell as an argument/parameter (instead of string interpolation) so it can’t alter the command text.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

@daanzu
Copy link
Copy Markdown
Author

daanzu commented Apr 22, 2026

Oops, I only now noticed #31 . There's a lot of good stuff in that one, and it should be merged, but I think the implementation here might be cleaner.

@daanzu
Copy link
Copy Markdown
Author

daanzu commented Apr 22, 2026

@copilot apply changes based on the comments in this thread

@mscolnick mscolnick requested a review from manzt April 23, 2026 15:34
@mscolnick
Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

@mscolnick
Copy link
Copy Markdown
Contributor

@daanzu it looks like copilot doesn't want to help. i merged my branch, let me know if that helps. happy to merge this if you want to resolve conflicts / comments

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.

3 participants