From owner-freebsd-questions@FreeBSD.ORG Fri Oct 27 20:42:40 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1E52816A403 for ; Fri, 27 Oct 2006 20:42:40 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id B973643D49 for ; Fri, 27 Oct 2006 20:42:39 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.6/8.13.8) id k9RKgcpJ066966; Fri, 27 Oct 2006 15:42:38 -0500 (CDT) (envelope-from dan) Date: Fri, 27 Oct 2006 15:42:37 -0500 From: Dan Nelson To: Volodymyr Kostyrko Message-ID: <20061027204237.GD5213@dan.emsphone.com> References: <454259FB.4020009@synergetica.dn.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <454259FB.4020009@synergetica.dn.ua> X-OS: FreeBSD 6.2-PRERELEASE X-message-flag: Outlook Error User-Agent: Mutt/1.5.13 (2006-08-11) Cc: freebsd-questions@freebsd.org Subject: Re: rc.subr question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2006 20:42:40 -0000 In the last episode (Oct 27), Volodymyr Kostyrko said: > I'm writing a custom script to start a linux daemon with > LinuxThreads. The script starts daemon nicely, but on stopping it > shows: > > Stopping fmsadmin. > kill: 19790: No such process > > This happens because all processes are actually threads and > signalling one process is as good as signalling them all. But with > this error wait_for_pids doesn't work which results in: > > yehat# /usr/local/etc/rc.d/fmsadmin restart > Stopping fmsadmin. > kill: 19790: No such process > fmsadmin already running? (pid=19776 19777 19778 19779 19780 19781 19782 > 19783 19784 19785 19786 19787 19788 19789 19791 19792 19793 19794 19795 > 19796 19797 19926 19927). > > What is the right way to describe such daemon in rc script? The daemon > doesn't create any pid files and killing one of active processes does > the thing. The best way is to record fmsadmin's primary pid to a file, either by having it write one, or recording it in the rc script using the $! variable (you'll need to write a custom start_cmd action to do this). Then if you set fmsadmin_pidfile=/path/to/pidfile in rc.conf, rc.d/fmsadmin will send its kill signal to the pid listed in that file, and will wait for just that pid to exit. -- Dan Nelson dnelson@allantgroup.com