The execv()
function expects an array of NULL
terminated strings but doesn't take the number of arguments. It uses a sentinel value (NULL
pointer) to determine when the array ends.
The man page for execv()
states...
The first argument, by convention, should point to the filename associated with the file being executed. The array of pointers must be terminated by a NULL pointer.
... so my question is....
I want to pass the argv
from main()
to execv()
.
Can I be assured that argv that comes into main is terminated by a NULL pointer?
That is, can I be assured that argv[argc] == NULL
or do I have to allocate my own char*
array of size argc
+ 1 and put NULL
in the argc
index?
If I can be assured, is it documented somewhere?
Thanks, ~Eric