Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. struct process {
  2. char ID[30];
  3. int pid;
  4. };
  5. typedef struct process Process;
  6.  
  7. int main (int argc,char*argv[]){
  8. int fdin, fdout, ret1, ret2, i, j, v;
  9. int n = 0;
  10. int* vPID;
  11. Process* p;
  12. Process temp;
  13.  
  14. p = (Process*)malloc(30*(sizeof(Process)));
  15.  
  16. if(fdin = open("entradaR.txt",O_RDONLY,0666) ==-1){
  17. printf("Error open()\n");
  18. return -1;
  19. }
  20. if(fdout = open("saidaR.txt",O_CREAT|O_TRUNC|O_WRONLY,0666) ==-1){
  21. printf("Error open()\n");
  22. return -1;
  23. }
  24.  
  25. if(ret1 = dup2(fdin,0) == -1){
  26. printf("Erro dup2(fdin,0) \n");
  27. return -2;
  28. }
  29. if(ret2 = dup2(fdout,1) == -1){
  30. printf("Erro dup2(fdout,1) \n");
  31. return -3;
  32. }
  33.  
  34. printf("%d", n);
  35. while(scanf("Process to execute: %s [^\n]", &p[n].ID ) != EOF){
  36. //printf("%d", n);
  37. //printf("%s \n", p[n].ID);
  38. n++;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement