Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. typedef struct _canal{
  2. int channel[2];
  3. }canal;
  4.  
  5. canal array_pipes[processos];
  6.  
  7. /*Pipe para cada uma das posições do array*/
  8.  
  9. while(true) {
  10. FD_ZERO(&read_set);
  11. highestFd=0;
  12. for (j=0;j<processos;j++){
  13. if (array_pipes[j].channel[0] > highestFd)
  14. highestFd = array_pipes[j].channel[0];
  15.  
  16. FD_SET(array_pipes[j].channel[0], &read_set);
  17.  
  18. selectRet = select(highestFd+1, &read_set, NULL, NULL, &t)
  19. if (selectRet < 0) {
  20. /* Error */
  21. //if ( errno != EINTR ) {
  22. // printf("True Error!\n");
  23. //}
  24. } else if (selectRet == 0) {
  25. /* Nothing to read */
  26. /* Should never happen!!! */
  27. } else {
  28. for (i=0; i < NUM_PROCESSES; i++) {
  29. if ( FD_ISSET(array_pipes[j].channel[0],&fdSet) ) {
  30. numRead++;
  31. //Código todo bacano aqui
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement