FYI checked that with -fake-multinode. Also checked that if I modify start_northd to pass $cmd (as ovsdb-server), it also correctly matches it (and failing when $cmd is anything different).
On Mon, Jun 13, 2022 at 8:45 PM Ihar Hrachyshka <ihrac...@redhat.com> wrote: > > [ -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: 09dc4866fd32 ("Handle re-used pids in pidfile_is_running") > Signed-off-by: Ihar Hrachyshka <ihrac...@redhat.com> > --- > v2: fixed several syntax errors. > v2: converted from one liner to a sequence of if-then checks. > v2: squashed with a patch that removes redundant [ -e $file ] check. > v1: initial version > --- > utilities/ovn-ctl | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl > index e2f05915b..23d4d7f8c 100755 > --- a/utilities/ovn-ctl > +++ b/utilities/ovn-ctl > @@ -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 > -- > 2.34.1 > _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev