From patchwork Mon Jun 20 16:44:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 9188249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C01DF6075F for ; Mon, 20 Jun 2016 17:08:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A990727A98 for ; Mon, 20 Jun 2016 17:08:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B82227B2F; Mon, 20 Jun 2016 17:08:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9976627A98 for ; Mon, 20 Jun 2016 17:08:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753722AbcFTRI2 (ORCPT ); Mon, 20 Jun 2016 13:08:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36650 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753641AbcFTRI1 (ORCPT ); Mon, 20 Jun 2016 13:08:27 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA1F0128262 for ; Mon, 20 Jun 2016 16:45:01 +0000 (UTC) Received: from steved.boston.devel.redhat.com (vpn-62-104.rdu2.redhat.com [10.10.62.104]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5KGj1Rv004280 for ; Mon, 20 Jun 2016 12:45:01 -0400 From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 1/1] start-statd: Use flock to serialize the running of this script Date: Mon, 20 Jun 2016 12:44:59 -0400 Message-Id: <1466441099-16166-1-git-send-email-steved@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 20 Jun 2016 16:45:01 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To once and for all stop multiple rpc.statd from being started (mostly in HA environments), use flock to serialize the running of the script Signed-off-by: Steve Dickson --- utils/statd/start-statd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/statd/start-statd b/utils/statd/start-statd index 19e6eb2..2fd6039 100755 --- a/utils/statd/start-statd +++ b/utils/statd/start-statd @@ -6,6 +6,10 @@ # site. PATH="/sbin:/usr/sbin:/bin:/usr/bin" +# Use flock to serialize the running of this script +exec 200> /var/run/rpc.statd.lock +flock -e 200 + if [ -s /var/run/rpc.statd.pid ] && [ 1`cat /var/run/rpc.statd.pid` -gt 1 ] && kill -0 `cat /var/run/rpc.statd.pid` > /dev/null 2>&1