-
Notifications
You must be signed in to change notification settings - Fork 24
Improve stale entry cleanup for cross-platform compatibility #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,10 +22,19 @@ for f in "$servers_dir"/*.json; do | |
|
|
||
| pid=$(jq -r '.pid' "$f" 2>/dev/null) || continue | ||
|
|
||
| # Clean up stale entries | ||
| if ! kill -0 "$pid" 2>/dev/null; then | ||
| rm -f "$f" | ||
| continue | ||
| # Clean up stale entries. Under MSYS/Cygwin, accept either a Windows-native | ||
| # process lookup or `kill -0` so we handle both Windows and Bash-owned PIDs. | ||
| 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 | ||
|
Comment on lines
+27
to
+29
|
||
| rm -f "$f" | ||
| continue | ||
| fi | ||
| else | ||
| if ! kill -0 "$pid" 2>/dev/null; then | ||
|
daanzu marked this conversation as resolved.
|
||
| rm -f "$f" | ||
| continue | ||
| fi | ||
| fi | ||
|
|
||
| entry=$(jq '.' "$f" 2>/dev/null) || continue | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
powershell.exeis unavailable on a given MSYS/Cygwin setup, this will emit a "command not found" error to stderr on every iteration (even though thekill -0fallback still works). Consider checkingcommand -v powershell.exefirst (or redirecting its stderr) to keep output clean and avoid noisy logs.There was a problem hiding this comment.
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