Correct way to call execve?

Leo Bicknell bicknell at ufp.org
Sun Jul 20 15:50:43 PDT 2003


In a message written on Sun, Jul 20, 2003 at 02:13:52PM -0700, Tim Kientzle wrote:
> If I declare argv as "const char *",
> then the call to execve() warns about
> "incompatible pointer type" for the
> second argument.

Almost, but the other order is important here, this passes gcc -Wall:

#include <unistd.h>
#include <paths.h>

int main(int argc, char *const argv[], char *const envp[]) {
  char *const execargv[] = { _PATH_BSHELL, NULL };

  execve(_PATH_BSHELL,execargv,envp);

  return 0;
}


-- 
       Leo Bicknell - bicknell at ufp.org - CCIE 3440
        PGP keys at http://www.ufp.org/~bicknell/
Read TMBG List - tmbg-list-request at tmbg.org, www.tmbg.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20030720/ec762d2f/attachment.bin


More information about the freebsd-hackers mailing list