Skip to content

Commit

Permalink
Fix pidfile_is_running when $cmd is not passed
Browse files Browse the repository at this point in the history
[ -z $string ] needs double quotes to handle zero-length strings
properly.

The function became a long one-liner; this patch converts it to a
version that is hopefully simpler to understand. (As a bonus, it no
longer violates the guideline for line length.)

Fixes: 09dc486 ("Handle re-used pids in pidfile_is_running")
Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
(cherry picked from commit 6e57adf)
  • Loading branch information
booxter authored and numansiddique committed Jun 14, 2022
1 parent 6172f6a commit 543c23c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions utilities/ovn-ctl
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,20 @@ ovn_ic_db_conf_file="$ovn_etcdir/ovn-ic-db-params.conf"
pidfile_is_running () {
pidfile=$1
cmd=$2
test -e "$pidfile" && [ -s "$pidfile" ] && pid=`cat "$pidfile"` && pid_exists "$pid" && [ -z $cmd -o pid_comm_check "$cmd" "$pid" ]
} >/dev/null 2>&1
if [ ! -s "$pidfile" ]; then
# file missing or empty
return 1
fi
pid=`cat "$pidfile"`
if ! pid_exists $pid; then
# pid is dead
return 1
fi
if [ -n "$cmd" ]; then
return $(pid_comm_check "$cmd" "$pid")
fi
return 0
}

stop_nb_ovsdb() {
OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovnnb_db $DB_NB_PIDFILE $DB_NB_CTRL_SOCK
Expand Down

0 comments on commit 543c23c

Please sign in to comment.