else { /* In the parent */ /* close unneeded endpoints */ close(reader[1]); close(writer[0]); /* Send something to the filter */ write(writer[1], msg, strlen(msg)); close(writer[1]); /* HERE I CLOSE PARENT->FILTER */ /* Read response from the filter */ printf("filter says:\n"); while ((nread = read(reader[0], buf, 9)) > 0) { buf[nread] = '\x0'; printf("%s", buf); } if (nread < 0) { perror("read(): "); return 1; } printf("\n"); close(reader[0]); /* HERE I CLOSE FILTER->PARENT */ } #### else { /* In the parent */ /* close unneeded endpoints */ close(reader[1]); close(writer[0]); while (msg = next_string_to_filter()) { /* Send something to the filter */ write(writer[1], msg, strlen(msg)); /* Read response from the filter */ read_and_consume_answer(reader[0]); } /* Close communication with filter */ close(writer[1]); close(reader[0]); }