/* execv.c - run the ls command from a C program using execv * 2009.09.23 Neal Nelson * Copied from Haviland & Salama, p93 * */ #include #include #include main() { char *argv[3]; argv[0] = "ls"; argv[1] = "-lt"; argv[2] = (char *)0; printf("Executing ls using execv ...\n"); execv("/bin/ls", argv); /* If execv returns, the call has failed */ perror("execv failed to run ls"); exit(1); }