From owner-freebsd-ports@FreeBSD.ORG Tue Jan 22 15:36:34 2013 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id CAD39BB8 for ; Tue, 22 Jan 2013 15:36:34 +0000 (UTC) (envelope-from glarkin@FreeBSD.org) Received: from mail1.sourcehosting.net (mail1.sourcehosting.net [74.205.51.45]) by mx1.freebsd.org (Postfix) with ESMTP id A7F90DF8 for ; Tue, 22 Jan 2013 15:36:34 +0000 (UTC) Received: from 24-181-237-39.dhcp.oxfr.ma.charter.com ([24.181.237.39] helo=Gregory-Larkins-iMac.local) by mail1.sourcehosting.net with esmtp (Exim 4.73 (FreeBSD)) (envelope-from ) id 1Txftm-0004BH-W8; Tue, 22 Jan 2013 10:36:33 -0500 Received: from Gregory-Larkins-iMac.local (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by Gregory-Larkins-iMac.local (Postfix) with ESMTPS id A9D10199C562; Tue, 22 Jan 2013 10:36:30 -0500 (EST) Message-ID: <50FEB1FE.3030709@FreeBSD.org> Date: Tue, 22 Jan 2013 10:36:30 -0500 From: Greg Larkin Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: Grzegorz Blach References: <50FEAE0D.5090505@diatel.upm.es> <50FEB055.8080601@roorback.net> In-Reply-To: <50FEB055.8080601@roorback.net> X-Enigmail-Version: 1.5 X-SA-Exim-Connect-IP: 24.181.237.39 X-SA-Exim-Mail-From: glarkin@FreeBSD.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail1.sourcehosting.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00, RCVD_IN_SORBS_DUL,RDNS_DYNAMIC,TVD_RCVD_IP autolearn=no version=3.3.1 Subject: Re: How to launch services that do not fork to background using the rc infrastructure? Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Version: 4.2 X-SA-Exim-Scanned: Yes (on mail1.sourcehosting.net) Cc: freebsd-ports@freebsd.org X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: glarkin@FreeBSD.org List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jan 2013 15:36:34 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 1/22/13 10:29 AM, Grzegorz Blach wrote: > On 01/22/2013 04:19 PM, Javier Mart=EF=BF=ADn Rueda wrote: >> The typical and simple rc.d script to launch a service has, >> esentially, the following: >>=20 >> . /etc/rc.subr >>=20 >> name=3DSERVICE rcvar=3DSERVICE_enable >>=20 >> command=3D"/usr/local/sbin/PROGRAM" >>=20 >> pidfile=3D/var/run/${name}.pid=20 >> SERVICE_enable=3D${SERVICE_enable:-"NO"} >>=20 >> load_rc_config ${name} run_rc_command "$1" >>=20 >> One of the ports (net/spread4) runs a PROGRAM that does not fork >> to background as a daemon and which does not have any >> command-line option to ask it to do so. Therefore, the rc.d >> script never finishes, with various consequences (system boot >> stops, no pid file generated...) >>=20 >> I tried adding a "&" to SERVICE_flags to see if it made it run in >> the background, but it didn't do the trick. I also quickly >> checked the /etc/rc.subr code to see if there is any way of >> forcing a background launch, but couldn't see anything. No luck >> searching the web or problem reports either. >>=20 >> So, my question is whether there is a non-obvious way of forcing >> a program to start in background using the rc infrastructure. >>=20 >=20 >=20 > Try command=3D"/usr/sbin/daemon -c -f -p $pidfile PROGRAM" or some > thing like this. >=20 Here's a full example of that in the ViewVC rc.d script: http://svnweb.freebsd.org/ports/head/devel/viewvc/files/viewvc.in?revisio= n=3D300896&view=3Dmarkup Hope it helps, Greg - --=20 Greg Larkin http://www.FreeBSD.org/ - The Power To Serve http://www.sourcehosting.net/ - Ready. Set. Code. http://twitter.com/cpucycle/ - Follow you, follow me -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (Darwin) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlD+sf4ACgkQ0sRouByUApAdBgCfdwmbfCokv0Rxm50pTaqZkAkF BGoAnjl27+rGvyV3DP4W5rsphL2dbZBd =3DVi59 -----END PGP SIGNATURE-----