Question 3 version 3 -- Corrected int main(int argc, char * argv[]) { int s, conn[2]; if (argc != 2) { fprintf(stderr, "usage: %s filename\n", argv[0]); exit(1); } pipe(conn); int p = fork(); if (p == 0) { close(2); dup(conn[1]); execlp("cc", "cc", argv[1], NULL); fprintf(stderr, "execlp failed\n"); exit(1); } close(conn[1]); int r = open("errors.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600); if (r < 0) { fprintf(stderr, "error creating errors.txt\n"); exit(1); } char buff[1024]; int errors = 0; while (1) { int n = read(conn[0], buff, 1024); if (n > 0) errors = 1; else break; write(2, buff, n); write(r, buff, n); } if (! errors) { printf("no errors\n"); execl("a.out", "a.out", NULL); } }