Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to implement a blocking read on a file on Unix/C ?

Status
Not open for further replies.

koblu

Programmer
Jun 11, 2004
2
US
I need to write a file reader function which will continuosly read a file being actively written to by another process. What is the best way to implement this blocking read efficiently ?
 
You mean like the [tt]tail -f[/tt] command?

--
 
I would use [tt]sleep[/tt], [tt]fread[/tt], [tt]feof[/tt] and [tt]clearerr[/tt] in a loop.

--------------------

Denis
 
Yes, kind of like the "tail -f" command. Is there a way to block a read or fread call without going to sleep ? I want this function to do minimal CPU hogging.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top