From owner-freebsd-questions@freebsd.org Wed Jun 1 14:08:24 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3816EB4F03E for ; Wed, 1 Jun 2016 14:08:24 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D32C11C82 for ; Wed, 1 Jun 2016 14:08:23 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: by mail-wm0-x22c.google.com with SMTP id z87so31231248wmh.0 for ; Wed, 01 Jun 2016 07:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=YHFDbZVNn8j+bWjAlMzBIXzeD3L4uHuPTPLyqrGZaHg=; b=wqm+GPdeUG+pXws5FdQ5mbN/IWcsZZgW+piVyz5e/IbXhNM1qYjUhmWQckJW4gt/rU mRvhtvymisKL0Kx29V1qzWH8AJkvGPtoJyDm4C5kpb53ZbI6F28OpeAc/hEbJ1f3pVYf ugIXm7XaRC2hq9omHpZCspH6nz1O8EUHVew2bNQpBjGf5+tGD+RZDtlSwYcsGi4LGVHv kY5sElECcRPYy0arJe7H1v++1JiAiEjWBgRd/MaTv84VMpoAmoNQAKxdKomrISue/uPI NNSwJkXhR6uvY4LexW9StsxnQX2yBYeQgG62hDZQ2bSlUod7Rwra06FqOz4ewqOXMd2T hTaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YHFDbZVNn8j+bWjAlMzBIXzeD3L4uHuPTPLyqrGZaHg=; b=GpqD5vKsNbwt3hehWO2t+MTyGLzyXc5LTWBts42KyZxd2k5PqJBL1QaXhHZaJ+6qtl Iaw3VYEQWzq9s7anGA6MjzKaVoBbyraryBHOu3rOMJypc7dOdbZJfYFMDt9pZBuCd4yw 26elj6SE+uTFIKhONmwH4/m7u+KX457ePJD822MTrhEU9rir2sqZ5A9wWNya5aapX8p4 5X73KcvY304ZK1YbO6rbTL25euizHo6lo8Cgavf4L5phaOCf5jykgyH+l73ZugE6VTHB ZFsgfGH6xrIsidG5wPxw4z8BYBGb6PG6cmWgIfxA6D5QxC3LVW2SKbVvSZ7uarLAgv5Y SIGw== X-Gm-Message-State: ALyK8tK/dm7KBkoPZ8+sUmdy6Xc8SiCd6iJMpEPPlxPMFiJVH1v9M2+szYTLpQ9/BOKv+w== X-Received: by 10.28.54.204 with SMTP id y73mr20624829wmh.59.1464790102403; Wed, 01 Jun 2016 07:08:22 -0700 (PDT) Received: from gumby.homeunix.com ([2.222.27.202]) by smtp.gmail.com with ESMTPSA id c185sm35380487wme.9.2016.06.01.07.08.20 for (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Jun 2016 07:08:21 -0700 (PDT) Date: Wed, 1 Jun 2016 15:08:19 +0100 From: RW To: freebsd-questions@freebsd.org Subject: Re: Pidfile generated by /usr/sbin/daemon not usable by rc.d script Message-ID: <20160601150819.42657954@gumby.homeunix.com> In-Reply-To: <20160601222416.Q15883@sola.nimnet.asn.au> References: <20160526193917.C15883@sola.nimnet.asn.au> <6ECB89F6-4410-47D2-AA9B-1EA63B334CF0@wooga.net> <20160601222416.Q15883@sola.nimnet.asn.au> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; amd64-portbld-freebsd10.2) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2016 14:08:24 -0000 On Wed, 1 Jun 2016 22:58:28 +1000 (EST) Ian Smith wrote: > On Wed, 1 Jun 2016 12:13:27 +0200, Adam Lindberg wrote: > > Sorry for the late reply. > > > > What we observed was that the `read _pid _junk < $_pidfile` line > > did indeed work on the command line, after sourcing /etc/rc.subr. > > For some strange reason it seems not to work from inside the > > service script for us. > > I just had another look at your foo.rcscript attachment, and bounced > through all in {/usr/local,}/etc/rc.d for examples. As RW said > earlier, 'command=yes' appears unlike all the others, in that it does > not provide the full pathname of the executable. I don't know if > that matters here. I did misunderstand that. When I saw 'command=yes' it looked like the OP was trying to treat command as a flag. > Also, none of the others (here) need daemon(8) to run, in background > or otherwise .. are you sure that you require its functionality for > 'foo'? Most daemons were written as such. daemon(8) is there for those that weren't or were written in a scripting language that doesn't support the double fork. > For one thing, it seems that daemon keeps the -p pidfile locked > during execution of the process; might that affect service status, > stop, etc? I think the problem is pretty straightforward. If you run this read _pid _junk < $_pidfile and $_pidfile doesn't end in a newline, read will wait for one, just as it would if you typed in a line and didn't hit return.