execvp: bad address error

The code seems to miss to NULL-terminate arrays[k]. Make the last entry in arrays[k] carry NULL.


Update:

This

  if (execvp((const char*) arrays[k][0], arrays[k]) < 1)

should be

  if (execvp(arrays[k][0], arrays[k]) == -1)

of even more straight forward just:

  execvp(arrays[k][0], arrays[k]);
  perror("execvp() failed");

as the members of the exec*()-family of functions return on error only.

Leave a Comment