#include "csapp.h" /* For each file mentioned on the command line, compile it along with "csapp.c" and suitable compiler flags. Compile all of them at once. Then run one of the generated programs. */ int main(int argc, char **argv) { int i; for (i = 1; i < argc; i++) { char * gccArgs[6] = { "gcc", "-Wall", "-O2", argv[i], "csapp.c", NULL }; pid_t pid = Fork(); if (pid==0){ Execve("/bin/gcc", gccArgs, environ); } } int j; int status; for (j = 1; j < argc; j++) { Waitpid(-1, &status, 0); } char* runArgs[2] = { "a.out", NULL }; if (WEXITSTATUS(status)==0){ Execve("./a.out", runArgs, environ); } return 1; }