Skip to content

Apache Lucene open-source search software

SOLR-13089: Fix lsof edge cases in the solr CLI script

Martijn Kosterac777a535222
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 44cec922161..73067e09af1 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -212,6 +212,8 @@ Bug Fixes
* SOLR-14122: SimUtils converts v2 to v1 request params incorrectly. (Li Cao, ab)
+* SOLR-13089: Fix lsof edge cases in the solr CLI script (Martijn Koster via janhoy)
+
Other Changes
---------------------
diff --git a/solr/bin/solr b/solr/bin/solr
index 580f344e664..b3ffecf0a6e 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -2241,13 +2241,13 @@ function start_solr() {
echo ""
fi
# no lsof on cygwin though
- if hash lsof 2>/dev/null ; then # hash returns true if lsof is on the path
+ if lsof -v 2>&1 | grep -q revision; then
echo -n "Waiting up to $SOLR_STOP_WAIT seconds to see Solr running on port $SOLR_PORT"
# Launch in a subshell to show the spinner
(loops=0
while true
do
- running=`lsof -PniTCP:$SOLR_PORT -sTCP:LISTEN`
+ running=$(lsof -t -PniTCP:$SOLR_PORT -sTCP:LISTEN)
if [ -z "$running" ]; then
slept=$((loops * 2))
if [ $slept -lt $SOLR_STOP_WAIT ]; then