8 /****************************************************************************
9 Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
13 ****************************************************************************/
14 int set_blocking(int fd, int set)
18 #define FLAG_TO_SET O_NONBLOCK
21 #define FLAG_TO_SET O_NDELAY
23 #define FLAG_TO_SET FNDELAY
27 if((val = fcntl(fd, F_GETFL, 0)) == -1)
29 if(set) /* Turn blocking on - ie. clear nonblock flag */
33 return fcntl( fd, F_SETFL, val);
50 set_blocking(fdpair[0], 0);
53 FD_SET(fdpair[0], &fds);
55 no = select(32, &fds, NULL, NULL, NULL);
58 ret = read(fdpair[0], buf, LEN);
60 fprintf(stderr,"Error: EOF on pipe\n");
64 printf("read %d bytes\n", ret);
67 write(fdpair[1], buf, 0);
69 write(fdpair[1], buf, LEN);