Correct way to call execve?

Tim Kientzle kientzle at acm.org
Mon Jul 21 11:21:41 PDT 2003


Chad David wrote:
> 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++.

Yes, the intent was to find a way to avoid copying the data.

I was hoping that someone knew a standard way to
say "yes, I really do mean to cast away that const,"
akin to C++ const_cast.

As far as I can tell, the POSIX-mandated declaration
of execvp is simply wrong.  (SUSv3 even has a comment
that essentially admits this fact and then vainly tries
to rationalize it.  <sigh>)

Basically, there is no const-correct way to
invoke execvp using literal strings for argv except
to copy the strings.  In particular, the
FreeBSD implementation of popen(), for example, cannot be
compiled with strict warnings.

Tim



More information about the freebsd-hackers mailing list