open_pipe.c 248 B

123456789101112131415
  1. #include <unistd.h>
  2. #include <fcntl.h>
  3. #include "open.h"
  4. #include "blocking.h"
  5. int open_pipe(int *fd)
  6. {
  7. int i;
  8. if (pipe(fd) == -1) return -1;
  9. for (i = 0;i < 2;++i) {
  10. fcntl(fd[i],F_SETFD,1);
  11. blocking_disable(fd[i]);
  12. }
  13. return 0;
  14. }