Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct _canal{
- int channel[2];
- }canal;
- canal array_pipes[processos];
- /*Pipe para cada uma das posições do array*/
- while(true) {
- FD_ZERO(&read_set);
- highestFd=0;
- for (j=0;j<processos;j++){
- if (array_pipes[j].channel[0] > highestFd)
- highestFd = array_pipes[j].channel[0];
- FD_SET(array_pipes[j].channel[0], &read_set);
- selectRet = select(highestFd+1, &read_set, NULL, NULL, &t)
- if (selectRet < 0) {
- /* Error */
- //if ( errno != EINTR ) {
- // printf("True Error!\n");
- //}
- } else if (selectRet == 0) {
- /* Nothing to read */
- /* Should never happen!!! */
- } else {
- for (i=0; i < NUM_PROCESSES; i++) {
- if ( FD_ISSET(array_pipes[j].channel[0],&fdSet) ) {
- numRead++;
- //Código todo bacano aqui
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement