From owner-freebsd-questions@FreeBSD.ORG Tue Oct 5 13:12:05 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24EFD106564A for ; Tue, 5 Oct 2010 13:12:05 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id A9B6D8FC08 for ; Tue, 5 Oct 2010 13:12:04 +0000 (UTC) Received: by wwb17 with SMTP id 17so8150238wwb.31 for ; Tue, 05 Oct 2010 06:12:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type:content-transfer-encoding; bh=MdskR/gWw67asfydO0eDfwWJjVLPeosPxADq2LuXNFM=; b=T2nOPwC/Afy9fexW12aCKkg9wl+u6xyXnHxcoPveTGK1Rhtt3eESC0dNcTY+v3rRv/ NEjxIAOHYCBouHMXRMt+W49LMXnLMfDhURz7uWrfjmNQqZkyKmls0XP+BCCBgsA+Fc9s xOgf6vWMZ9lEXEUzegVbWPIcm/C8v4m4T6Ofc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=date:from:to:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=D4UB2dEgzPenzymvMNz1e678gpPQsIbKzlc9k9NAAI8Mev3hKvD4mLPkVaBYA0+Suo bJTmY4N3dhBJ8nR9SKxVjqmtVgnE4CIcpD9/Q0LBEYC5mn3OpwhJQPexXppFOqp7WXZL 15WfhcneWKCK5mmS/vlHM5u1mboCMX2tjUdds= Received: by 10.227.152.75 with SMTP id f11mr9125278wbw.191.1286284323683; Tue, 05 Oct 2010 06:12:03 -0700 (PDT) Received: from gumby.homeunix.com (bb-87-81-140-128.ukonline.co.uk [87.81.140.128]) by mx.google.com with ESMTPS id e31sm5338614wbe.5.2010.10.05.06.12.01 (version=SSLv3 cipher=RC4-MD5); Tue, 05 Oct 2010 06:12:02 -0700 (PDT) Date: Tue, 5 Oct 2010 14:11:58 +0100 From: RW To: freebsd-questions@freebsd.org Message-ID: <20101005141158.4730dab3@gumby.homeunix.com> In-Reply-To: <86d3ronb01.fsf@srvbsdfenssv.interne.associated-bears.org> References: <86d3ronb01.fsf@srvbsdfenssv.interne.associated-bears.org> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; i386-portbld-freebsd8.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: Custom rc script using /usr/sbin/daemon 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: Tue, 05 Oct 2010 13:12:05 -0000 On Tue, 05 Oct 2010 13:18:38 +0200 Eric Masson wrote: > Hello, > > I'm trying to create a script that would launch php-cgi in fastcgi > mode. So far, I've the following script : > >... > > sig_stop="TERM" > pidfile="/var/run/${name}/${name}.pid" > command="/usr/sbin/daemon -f -p ${pidfile} /usr/local/bin/php-cgi" I don't think you can do it like that. IIRC when you try to stop a daemon it doesn't just kill the process by pid, it also sanity checks the command in case the daemon has died and the pid was reused. Since "daemon" wont show-up in the ps output it can't be in the command variable. I think you need to write a start function, something like this: start_cmd="phpfastcgi_start" command="/usr/local/bin/php-cgi" phpfastcgi_start(){ echo "starting phpfastcgi." /usr/sbin/daemon -f -p ${pidfile} ${command} }