Since pids can be re-used, it is necessary to check that the process that is running with a pid matches the one that we expect.
This adds the ability to optionally pass a 'binary' argument to pidfile_is_running, and if it is passed to match the binary against /proc/$pid/exe. Signed-off-by: Terry Wilson <twil...@redhat.com> --- utilities/ovn-ctl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl index d733aa42d..41fa89770 100755 --- a/utilities/ovn-ctl +++ b/utilities/ovn-ctl @@ -40,9 +40,16 @@ ovn_ic_db_conf_file="$ovn_etcdir/ovn-ic-db-params.conf" ## start ## ## ----- ## +pid_exe_matches () { + pid=$1 + binary=$2 + [ -z "$binary" -o `readlink /proc/$pid/exe` = "$binary" ] +} + pidfile_is_running () { pidfile=$1 - test -e "$pidfile" && [ -s "$pidfile" ] && pid=`cat "$pidfile"` && pid_exists "$pid" + binary=$2 + test -e "$pidfile" && [ -s "$pidfile" ] && pid=`cat "$pidfile"` && pid_exists "$pid" && pid_exe_matches "$pid" "$binary" } >/dev/null 2>&1 stop_nb_ovsdb() { -- 2.34.3 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev