A question about read() system call!!

Doug Yip dougy at hpsciz.sc.hp.com
Thu May 23 07:52:13 AEST 1991


>  I wonder if I can get help regarding the unix system call "read()".
>When a program executes this system call to read from an empty pipeline,  
>shouldn't it return zero ( nothing is read ) and passes control to the next 
>statement? I think it remains stuck waiting for something to be put it the 
>pipeline. How can I overcome this behaviour? That is making it pass control 
>to next statement even if pipeline is empty. I would appreciate responses.

   
There are two options to solve this problem:

If the file is already open, you can do a fcntl(fd,F_SETFL,O_NDELAY).

If the file is not open yet, you can specify the O_NDELAY option when you
open the file.

You need to include the following files for the options to work according
to my manual:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>



More information about the Comp.unix.questions mailing list