read not blocking on named pipe
问题 i have the following bit of C code which reads from a pipe and then should block but it never blocks int pipe_fd; int res; int open_mode = O_RDONLY; char buf[100]; int bytes_read = 0; memset (buf, '\0', sizeof(buf)); pipe_fd = open(FIFO_NAME, open_mode); if (access(FIFO_NAME, F_OK) == -1) { res = mkfifo(FIFO_NAME, 0777); if (res != 0) { fprintf (stderr, "Could not create fifo %s\n", FIFO_NAME); exit (EXIT_FAILURE); } } for(;;) { do { res = read(pipe_fd, buf, sizeof(buf)); bytes_read += res;