Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. if (pid == 0) {
  2.  
  3.     char* outputFile = redirectOutput(args);
  4.     int fdOut;
  5.  
  6.     if (outputFile == NULL)
  7.         fdOut = 1;
  8.  
  9.     else {
  10.         printf("%s\n", outputFile);
  11.  
  12.         if ((fdOut = open(outputFile, O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) == -1)
  13.             printf("error on open");
  14.  
  15.         close(fileno(stdout));
  16.         dup2(fdOut,1);
  17.     }
  18.     execvp(command,array);
  19.     exit(0);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement