vexec function(s)?

Guy Harris guy at auspex.uucp
Thu Jul 26 04:24:00 AEST 1990


From:  guy at auspex.uucp (Guy Harris)

>What I appear to need here is either:
>
>	a)  a standard way to convert a va_list into a list of pointers
>	    (to argument values), or

I suspect "different_execvp" is misnamed; given the "va_list", it
appears to have a calling sequence more like "execlp" - i.e.,

	different_execlp("/bin/explode", "explode", "bright blue light",
	    (char *)NULL);

Given that, you could scan the argument list twice; the first time,
you'd count the number of arguments, then you'd malloc up an array of
N+1 "char *"s, and scan the argument list a second time filling in that
array.  Now "argv" is a pointer to the first element of that array....

>None of these things are a part of standard ANSI C (as far as I know).

The second isn't; the first can be done in ANSI C, unless I've missed
something subtle in the spec that forbids traversing the argument list
twice (I just checked and didn't see anything obvious).

>Are any of them a part of POSIX?

Nope.

>If not, why not?

Because the first can be done in ANSI C (or pre-ANSI C with <varargs.h>).

Volume-Number: Volume 20, Number 145



More information about the Comp.std.unix mailing list