From owner-freebsd-rc@FreeBSD.ORG Tue Oct 10 01:56:21 2006 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 276A916A416 for ; Tue, 10 Oct 2006 01:56:21 +0000 (UTC) (envelope-from dat1965@yahoo.com) Received: from web55109.mail.re4.yahoo.com (web55109.mail.re4.yahoo.com [206.190.58.158]) by mx1.FreeBSD.org (Postfix) with SMTP id E361F43D45 for ; Tue, 10 Oct 2006 01:56:19 +0000 (GMT) (envelope-from dat1965@yahoo.com) Received: (qmail 3494 invoked by uid 60001); 10 Oct 2006 01:56:19 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=cDlvjFGXi0J+yIa3XE3vXWmDvwmfxQzbiwdJ4K2nhcovB9uZmuy1mgao8Pbkt/1JgB8594hrXm2CI8kkg+sGpH/vpYzeep9e6wxKmUHg+JstK5wmZ4GsITLR4Kqu5YE1E1wl1soc72U/P0FZ8+00ftuIIdeFN1RlxX1xjvLFW4U= ; Message-ID: <20061010015619.3492.qmail@web55109.mail.re4.yahoo.com> Received: from [67.131.247.220] by web55109.mail.re4.yahoo.com via HTTP; Mon, 09 Oct 2006 18:56:19 PDT Date: Mon, 9 Oct 2006 18:56:19 -0700 (PDT) From: David Thompson To: Yar Tikhiy , freebsd-rc@freebsd.org In-Reply-To: <20061009122342.GB2805@comp.chem.msu.su> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: Subject: Re: Revised article on rc.d X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Oct 2006 01:56:21 -0000 --- Yar Tikhiy wrote: > After a long delay, I got down to my article on rc.d again. Many > thanks to Gary W. Swearingen for his valuable remarks. The new > version is available at http://people.freebsd.org/~yar/rcng/ . I > think this version can be added to our articles collection after a > few corrections that may be suggested by the readers. ;-) Regarding this paragraph, Note: An rc.d script must be written in the sh(1) language. It cannot be a binary executable because rc.d can opt to feed such scripts into a single instance of sh(1) instead of running each of them separately. This is controlled by an rc.conf(5) variable named rc_fast_and_loose. An rc.d script cannot be written in awk(1) or an interpreted language from ports for the same reason; in addition, it must be runnable early in the system startup sequence, before /usr has been mounted. This caveat is not really true in the strict technical sense. Consider if someone adds this line to their /etc/rc.d script, # KEYWORD: nostart then /etc/rc will not execute this script since rcorder is invoked with '-s nostart'. Thus the reasoning due to the $rc_fast_and_loose variable is not strictly accurate. That is, a script could technically be written in any interpreted language that happens to use '#' as its comment character; as long as the above comment line was added to the script. The problem is, of course, such scripts have to provide their own scaffolding, since rc.subr is written in sh(1); and the script cannot be run directly by /etc/rc due to the use of the sh(1) dot '.' operator (thus it needs 'KEYWORD: nostart' so that /etc/rc will skip it). Although not exactly clear in the above paragraph, the reason files in /etc/rc.d cannot be binary is because rc.d uses the sh(1) dot '.' operator *for all* invocations, like this, if [ -n "$rc_fast_and_loose" ]; then set $_arg; . $_file else ( trap "echo Script $_file interrupted; kill -QUIT $$" 3 trap "echo Script $_file interrupted; exit 1" 2 set $_arg; . $_file ) fi But for '.', files in /etc/rc.d *could* be binary, but even then rcorder expects to process text files, not binary files. rcorder uses fparseln() to read each file, but this doesn't really affect reading a binary file. Thus rcorder processes binary files benignly, try 'rcorder /bin/*' and you'll see consistent output. Also in that paragraph, when I read this, ... a binary executable because rc.d can opt to feed ... ^^^^ IMHO, it should probably say, ... a binary executable because /etc/rc can opt to feed ... ^^^^^^^ though I understand you're referring to the rc.d system, some clarity is gained in that sentence by using /etc/rc. -- David __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com