Arguments to execve

Peter LaDow petela@gocougs.wsu.edu
Tue Jun 11 20:52:00 GMT 2013


On Tue, Jun 11, 2013 at 1:42 PM, Carlos O'Donell <carlos@redhat.com> wrote:
> The standard dictates what should happen for your program to be portable
> and standards conforming.
>
> The above code you quote is not portable since it violates the standard.

Exactly.  We were just surprised that it did work correctly.

> We are not going to change the behaviour of execve on Linux to return
> EINVAL if envp is NULL since that might break non-portable programs
> on Linux that currently work. We would break these programs for no
> reward.

Well, I suppose the only reward would be to catch those cases where it
is not portable.  Perhaps updating the function attribute to include
envp as nonnull?  I.e.:

-extern int execve (__const char *__path, char *__const __argv[],
-                   char *__const __envp[]) __THROW __nonnull ((1, 2));
+extern int execve (__const char *__path, char *__const __argv[],
+                   char *__const __envp[]) __THROW __nonnull ((1, 2, 3));


> It might be useful to document this shortcut of using NULL in the
> manual pages (provided by the Kernel Man Pages project) and the glibc
> manual (part of the glibc source e.g. manual/*).

Sure.  As long as the syscall continues to silently implement this
shortcut.  I'll pursue an update to the man pages.

Pete



More information about the Libc-help mailing list