Date: Mon, 21 Jul 2003 11:42:06 -0600 From: Chad David <davidc@issci.ca> To: hackers@freebsd.org, Tim Kientzle <kientzle@acm.org> Subject: Re: Correct way to call execve? Message-ID: <20030721174206.GA21892@colnta.acns.ab.ca> In-Reply-To: <20030721172321.GA57666@ussenterprise.ufp.org> References: <3F1B0610.90803@acm.org> <20030720225041.GA26277@ussenterprise.ufp.org> <3F1C0C91.6050203@acm.org> <20030721165735.GA56766@ussenterprise.ufp.org> <20030721171538.GA21656@colnta.acns.ab.ca> <20030721172321.GA57666@ussenterprise.ufp.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jul 21, 2003 at 01:23:21PM -0400, Leo Bicknell wrote: > In a message written on Mon, Jul 21, 2003 at 11:15:38AM -0600, Chad David wrote: > > Try cc -Wwrite-strings -Wcast-qual exec.c. > > > > You cannot simply cast away a const. > > Grumble, will someone give me all the warnings you want turned on so I > can work around all of them? :) > > % cat exec.c > > #include <unistd.h> > #include <paths.h> > #include <string.h> > > int main(int argc, char *const argv[], char *const envp[]) { > char *const execargv[] = { strdup(_PATH_BSHELL), strdup(NULL) }; > > execve(_PATH_BSHELL,execargv,envp); > > return 0; > } > % cc -Wwrite-strings -Wcast-qual exec.c > % cc -Wall exec.c You can/should probably skip the strdup(NULL), or ensure V in malloc.conf :). I assumed it was obvious that you could copy the data, but I believe the intent of the original question was to find an alternative. As far as I know there isn't one. A const is a const, except in C++. -- Chad David davidc@issci.ca www.FreeBSD.org davidc@freebsd.org ISSci Inc. Calgary, Alberta Canada
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030721174206.GA21892>