/*------------------------------------------------------------------*/ /* textexec.c */ /* Author: Bob Dondero */ /* The exec and perror system calls. */ /*------------------------------------------------------------------*/ #include #include #include int main(int argc, char *argv[]) { char *ppcArgv[2]; printf("testexec process (%d)\n", (int)getpid()); ppcArgv[0] = "hello"; ppcArgv[1] = NULL; execvp(ppcArgv[0], ppcArgv); perror(argv[0]); return EXIT_FAILURE; } /*------------------------------------------------------------------*/ /* Sample executions: $ gcc -Wall -ansi -pedantic hello.c -o hello $ gcc -Wall -ansi -pedantic testexec.c -o testexec $ testexec testexec process (14067) hello process (14067) $ mv hello nothello $ testexec testexec process (14308) testexec: No such file or directory $ mv nothello hello $ testexec testexec process (14340) hello process (14340) */