Skip to content

Commit 44887e9

Browse files
jrvb-rlclaude
andcommitted
Fix test script to work without lsof on CI
Use ss or fuser as fallbacks when lsof is not available, and warn gracefully if none are present. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3c483bd commit 44887e9

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

scripts/test

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@ function steady_is_running() {
1414
}
1515

1616
kill_server_on_port() {
17-
pids=$(lsof -t -i tcp:"$1" || echo "")
17+
if command -v lsof >/dev/null 2>&1; then
18+
pids=$(lsof -t -i tcp:"$1" || echo "")
19+
elif command -v ss >/dev/null 2>&1; then
20+
pids=$(ss -tlnp "sport = :$1" 2>/dev/null | grep -oP 'pid=\K[0-9]+' || echo "")
21+
elif command -v fuser >/dev/null 2>&1; then
22+
pids=$(fuser "$1/tcp" 2>/dev/null || echo "")
23+
else
24+
echo "Warning: no tool available to find processes on port $1"
25+
return
26+
fi
1827
if [ "$pids" != "" ]; then
19-
kill "$pids"
28+
kill $pids
2029
echo "Stopped $pids."
2130
fi
2231
}

0 commit comments

Comments
 (0)