From patchwork Wed Jun 8 13:29:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Wilson X-Patchwork-Id: 1640521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=e6SZcJxe; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LJ7P02QbGz9sFk for ; Wed, 8 Jun 2022 23:29:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E1BCF424B5; Wed, 8 Jun 2022 13:29:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RMaYPqGNhk6G; Wed, 8 Jun 2022 13:29:19 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id D772C416DD; Wed, 8 Jun 2022 13:29:18 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 97387C0032; Wed, 8 Jun 2022 13:29:18 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 991F5C002D for ; Wed, 8 Jun 2022 13:29:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 74AEB60BEF for ; Wed, 8 Jun 2022 13:29:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LnzG19yy5Wde for ; Wed, 8 Jun 2022 13:29:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id D7B1B60BE6 for ; Wed, 8 Jun 2022 13:29:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654694955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NGY2vNpB9iLaz1bejeD8dXw0236x73ULIaAPL+xc7lc=; b=e6SZcJxeDY2yCyY3KO9UJWa+5TIs5eDUPjVqz2GeIWV2mMDd4MEY5RzK9tvO6/bd38rf4/ uipK6b3vrmN8JzY1vvfWPV4kmyUzsT7EOeFtVD5vi/94+pxG08NBgSJ0ZtcfmKyAMVunY+ tjBOffRkPg5KQ1RuiZKlwB9aDqB0VBM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-102-gE7X_LrYNX2XXo09IX9PQg-1; Wed, 08 Jun 2022 09:29:14 -0400 X-MC-Unique: gE7X_LrYNX2XXo09IX9PQg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11C0A185A7A4 for ; Wed, 8 Jun 2022 13:29:14 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.33.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id D690B404E4B5; Wed, 8 Jun 2022 13:29:13 +0000 (UTC) From: Terry Wilson To: dev@openvswitch.org Date: Wed, 8 Jun 2022 08:29:11 -0500 Message-Id: <20220608132912.3209028-1-twilson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=twilson@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v5 ovn 1/2] Handle re-used pids in pidfile_is_running X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 --- utilities/ovn-ctl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl index d733aa42d..14d37a3d6 100755 --- a/utilities/ovn-ctl +++ b/utilities/ovn-ctl @@ -42,7 +42,8 @@ ovn_ic_db_conf_file="$ovn_etcdir/ovn-ic-db-params.conf" pidfile_is_running () { pidfile=$1 - test -e "$pidfile" && [ -s "$pidfile" ] && pid=`cat "$pidfile"` && pid_exists "$pid" + 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 stop_nb_ovsdb() {