Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (pid == 0) {
- char* outputFile = redirectOutput(args);
- int fdOut;
- if (outputFile == NULL)
- fdOut = 1;
- else {
- printf("%s\n", outputFile);
- if ((fdOut = open(outputFile, O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) == -1)
- printf("error on open");
- close(fileno(stdout));
- dup2(fdOut,1);
- }
- execvp(command,array);
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement