[LCP]read error

Bill Rausch William.Rausch at numerical.com
Wed Apr 24 17:10:06 UTC 2002


Process B needs an O_APPEND on the open().

Bill


At 2:16 PM +0530 4/23/02, Hemant Mohan wrote:
>I am writing a program whereby I am opening a FIFO for reading. However the
>read is getting blocked though another process has already written to the
>FIFO and no other process is accesiing this FIFO.
>the program is something like:
>
>Process A
>main()
>{
>     int fd;
>     fd=open(FIFO, RD_ONLY );
>     read(fd, ....)
>}
>
>Process B
>main()
>{
>     mkfifo(FIFO, 0664);
>     fd =open(FIFO, WR_ONLY);
>     write(fd, ...);
>     printf("data written to fifo¥n");
>}
>
>Process B is run before process A, and the printf statement is desiplayed on
>the screen.
>But I find that inspite of this process B is blocked on the read as if there
>is no data in the FIFO.
>
>However if in process B, the open is done in non blocking mode
>fd = open(FIFO, RD_ONLY | O_NONBOCK)
>then it doesn't block on read, but read returns a negative value and the
>errorno is set, with the message "Resource temporarily unavailable".
>
>My question is that why does the read block initially, when there is some
>data for it to read. Under what conditions does the read normally block.
>
>
>Thanks,
>Hemant Mohan
>
>_______________________________________________
>This is the Linux C Programming List
>:  http://lists.linux.org.au/listinfo/linuxcprogramming List


-- 
Bill Rausch, Software Development, UNIX, Mac, Windows
Numerical Applications, Richland, WA  509-943-0861




More information about the linuxCprogramming mailing list