#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main(void) {
int fd[2], pipeAttr;
/*fd[0] for reader, fd[1] for writer*/
pipe(fd);
fnctl(fd[0], pipeAttr, F_GETFL);
pipeAttr |= O_NONBLOCK;
fnctl(fd[0], F_SETFL,
pipeAttr);
do_something(fd);
close(fd[0]);
close(fd[1]);
}
viod do_something(int fd[]) {
/*......*/
}
No comments:
Post a Comment