Change the executing of a 0-byte file to be an error...
hartmut.brandt at dlr.de
Fri Jun 10 12:00:09 GMT 2005
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>> > If a file is empty and executable, that empty file can be
GAD>> > executed without generating any error.
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>> $ sh
GAD>> $ PS1='sh$ '
GAD>> sh$ touch empty ; chmod +x empty
GAD>> sh$ ./empty
GAD>> sh$ echo $?
GAD>> sh$ PS1='zsh$ ' zsh
GAD>> zsh$ zsh
GAD>> zsh$ ./empty
GAD>> zsh: exec format error: ./empty
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>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.
More information about the freebsd-standards