The execv API

The execv(3) API's signature is:

int execv(const char *path, char *const argv[]);

As can be seen, the first parameter is the pathname of the successor process. The second parameter is, similar to the environment list above, a two-dimensional array of strings (each of them NULL-terminated) holding all the arguments to pass to the successor, starting from argv[0]. Think about it, it's identical to what we, C programmers, are so used to; this is the signature of the main() function in C:

int main(int argc, char *argv[]);

argc, of course, is the number of parameters received, including the program name itself (held in argv[0]), and argv is a pointer to a two-dimensional array of strings (each of them NULL-terminated) holding all ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.