coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: That '[' file in /usr/bin


From: H. Peter Anvin
Subject: Re: That '[' file in /usr/bin
Date: Sat, 02 Mar 2013 21:40:14 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3

On 03/02/2013 08:18 PM, Mike Frysinger wrote:
> 
> an example of why argv[0] can be bad: doing execve with argv[0] set
> to NULL is not an error, and apps that rely on argv[0] will usually
> segfault immediately. or they won't be able to figure out how
> they're supposed to behave.
> 

Invalid example.

You are talking about a bug; a miscoded application.  Incidentally
this is an error common to a lot of application regardless of this or not.

Any application that depends on argv[0] obviously needs to decide on
its fallback behavior: either error out or apply a default.

I think the only *valid* reason for not relying on argv[0] is that it
can result in unexpected behavior for symlinks.

> 
> personally, i find it a bit ironic that a lot of GNU apps
> (including coreutils) simply abort() themselves when argv[0]==NULL
> considering the project's hard line position about not relying on
> argv[0] for behavior.
> 

Quite.

        -hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]