#include #include #include #include int main(int arg, char **argv) { /* argv[1] is the "output" */ int fd = creat(argv[1], 0600); if (fd == -1) perror("creat"), exit(1); /* Redirect stdout (1) to "fd" */ if (dup2(fd, 1) == -1) perror("dup2"), exit(1); /* int c; */ /* while ((c = fgetc(stdin)) != EOF) */ /* fputc(c, stdout); */ execlp("cat", "cat", NULL); }