From owner-freebsd-arch@FreeBSD.ORG Fri Jun 10 12:00:09 2005 Return-Path: X-Original-To: freebsd-arch@FreeBSD.ORG Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 773B616A41F; Fri, 10 Jun 2005 12:00:09 +0000 (GMT) (envelope-from Hartmut.Brandt@dlr.de) Received: from smtp-1.dlr.de (smtp-1.dlr.de [195.37.61.185]) by mx1.FreeBSD.org (Postfix) with ESMTP id E732E43D1D; Fri, 10 Jun 2005 12:00:08 +0000 (GMT) (envelope-from Hartmut.Brandt@dlr.de) Received: from beagle.kn.op.dlr.de ([129.247.173.6]) by smtp-1.dlr.de over TLS secured channel with Microsoft SMTPSVC(6.0.3790.211); Fri, 10 Jun 2005 14:00:07 +0200 Date: Fri, 10 Jun 2005 14:00:06 +0200 (CEST) From: Harti Brandt X-X-Sender: brandt_h@beagle.kn.op.dlr.de To: Garance A Drosihn In-Reply-To: Message-ID: <20050610135808.J615@beagle.kn.op.dlr.de> References: <20050610111103.GE14221@submonkey.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-OriginalArrivalTime: 10 Jun 2005 12:00:07.0845 (UTC) FILETIME=[F21C6D50:01C56DB3] Cc: Ceri Davies , freebsd-standards@FreeBSD.ORG, freebsd-arch@FreeBSD.ORG Subject: Re: Change the executing of a 0-byte file to be an error... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Harti Brandt List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jun 2005 12:00:09 -0000 On Fri, 10 Jun 2005, Garance A Drosihn wrote: GAD>At 12:11 PM +0100 6/10/05, Ceri Davies wrote: GAD>> On Fri, Jun 10, 2005, Garance A Drosihn wrote: GAD>> > GAD>> > If a file is empty and executable, that empty file can be GAD>> > executed without generating any error. GAD>> GAD>> Are you sure? It seems to be a function of the shell more than GAD>> anything; the transcript below does exactly the same on both GAD>> FreeBSD 4-STABLE and Solaris 8: GAD>> GAD>> $ sh GAD>> $ PS1='sh$ ' GAD>> sh$ touch empty ; chmod +x empty GAD>> sh$ ./empty GAD>> sh$ echo $? GAD>> 0 GAD>> sh$ PS1='zsh$ ' zsh GAD>> zsh$ zsh GAD>> zsh$ ./empty GAD>> zsh: exec format error: ./empty GAD>> zsh$ GAD> GAD>Well, zsh can certainly add whatever processing it likes, but my main GAD>interest is what routines like 'exec()' will do with the file. In GAD>particular, I'm concerned with what happens when either `make' or `sh' GAD>execute some 0-byte file, because those are commands which will be GAD>doing the most command-executing in the process of `make buildworld'. GAD> GAD>I'll admit I did not notice that zsh made that check, as I only checked GAD>with `sh', `bash', and (inadvertently) `make'. It might be that the GAD>kernel is already doing the right thing, and what I actually need to GAD>change is `sh' and `make' instead of something in the kernel. I'm GAD>certainly willing to figure out what needs to be changed, but I GAD>thought I should first see if there are any reasons that I should not GAD>make such a change in the first place. make either uses a shell to execute a command or it uses execl() (depending whether you're in -j or -B mode and whether the line contains shell metacharacters or builtins), so when execl() does the right thing and the shell too, there is nothing to change in make. harti