From patchwork Tue Jul 12 23:27:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 969592 X-Patchwork-Delegate: alexne@voltaire.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6CNRfFE028126 for ; Tue, 12 Jul 2011 23:27:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756295Ab1GLX1l (ORCPT ); Tue, 12 Jul 2011 19:27:41 -0400 Received: from nspiron-3.llnl.gov ([128.115.41.83]:20163 "EHLO smtp.llnl.gov" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756243Ab1GLX1k (ORCPT ); Tue, 12 Jul 2011 19:27:40 -0400 X-Attachments: None Received: from eris.llnl.gov (HELO trebuchet) ([134.9.2.84]) by smtp.llnl.gov with SMTP; 12 Jul 2011 16:27:40 -0700 Date: Tue, 12 Jul 2011 16:27:40 -0700 From: Ira Weiny To: Alex Netes Cc: "linux-rdma@vger.kernel.org" , Aleksey Senin Subject: Re: [PATCH] opensm: Add support for PID file Message-Id: <20110712162740.29e2d7d1.weiny2@llnl.gov> In-Reply-To: <20110710120442.GA11284@localhost.localdomain> References: <20110710120442.GA11284@localhost.localdomain> X-Mailer: Sylpheed 3.1.1 (GTK+ 2.18.9; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 12 Jul 2011 23:27:41 +0000 (UTC) I agree this is an issue. However, usually the PID is generated from the startup script so that only the PID which is started by it is stopped. Specifically, think of the use case of starting multiple SM's on different ports. For example a local user may do this to manage 2 subnets from one node. Your patch will, by default, overwrite the PID file with each instance. (yes --pid-file can be specified but this is not very standard.) I think a better (and more standard) approach is to do the following (untested): --- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/scripts/opensm.init.in b/scripts/opensm.init.in index 0c84bd3..1e053c4 100644 --- a/scripts/opensm.init.in +++ b/scripts/opensm.init.in @@ -42,6 +42,8 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ +piddir=@localstatedir@ +PIDFILE=${piddir}/opensm.pid # Source function library. if [[ -s /etc/init.d/functions ]]; then @@ -62,7 +64,7 @@ fi start () { echo -n "Starting opensm: " - @sbindir@/opensm --daemon $OPTIONS > /dev/null + daemon --pidfile=$PIDFILE @sbindir@/opensm --daemon $OPTIONS > /dev/null if [[ $RETVAL -eq 0 ]]; then touch /var/lock/subsys/opensm success @@ -74,7 +76,7 @@ start () { stop () { echo -n "Shutting down opensm: " - killproc opensm + killproc -p $PIDFILE opensm if [[ $RETVAL -eq 0 ]]; then rm -f /var/lock/subsys/opensm success @@ -85,7 +87,8 @@ stop () { } Xstatus () { - pid="`pidof opensm`" + pid=`cat $PIDFILE` + ps -p $pid ret=$? if [ $ret -eq 0 ] ; then echo "OpenSM is running... pid=$pid" @@ -117,11 +120,11 @@ case "$1" in [ -e /var/lock/subsys/opensm ] && restart ;; resweep) - killall -HUP opensm + kill -s 1 `cat $PIDFILE` RETVAL=$? ;; rotatelog) - killall -USR1 opensm + kill -s 10 `cat $PIDFILE` RETVAL=$? ;; *)