null execve parameters

Alex Waugh Alex.Waugh at arm.com
Fri Oct 18 01:33:55 PDT 2002


Linux, and probably others, allow the argv and envp parameters to execve
to be null, indicating an empty list. I suggest we do the same.

Alex

Index: unixlib/source/sys/exec.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/sys/exec.c,v
retrieving revision 1.2.2.12
diff -u -r1.2.2.12 exec.c
--- unixlib/source/sys/exec.c	24 Sep 2002 13:32:47 -0000	1.2.2.12
+++ unixlib/source/sys/exec.c	18 Oct 2002 08:31:49 -0000
@@ -167,9 +167,16 @@
    char *cli;
    char pathname[MAXPATHLEN];
    int nasty_hack = 0;
+  char *null_list = NULL;

-  if (! execname || ! argv || ! envp)
+  if (! execname)
      return __set_errno (EINVAL);
+
+  if (! argv)
+    argv = &null_list;
+
+  if (! envp)
+    envp = &null_list;

  #ifdef DEBUG
    __os_print ("-- execve: function arguments\r\n");





More information about the gcc mailing list