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.