LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2011, 08:44 AM   #1
avee137
Member
 
Registered: Apr 2010
Location: bangalore,india
Distribution: ubuntu 9.10,CentOS 5
Posts: 120

Rep: Reputation: 16
how to clear system space buffers associated with read() call ?


I have a code that reads a file descriptor in an infinite loop.
like :
Code:
{
   int fd ;
   char buf10[10] = {'\0'} ;
   fd = open ("/dev/somePort",O_RDWR);
   while(1){
       read(fd ,buf10,5 );
       //do some operation on buf10


       //here i want to clear the system space buffer/cache associated   
       //with read()     
       } 
}
Is there any system call available in linux which could do that?

Any relevant help would be greatly appreciated.
 
Old 09-23-2011, 10:37 AM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
The only thing I can think of is to set the pipe to non-blocking mode and keep reading until you get EAGAIN or EWOULDBLOCK, then set it to blocking mode again for the next iteration.
Kevin Barry
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Read System Call is getting blocked when tried to read the data from CDC device sanju.lnt Linux - Embedded & Single-board computer 0 09-11-2011 11:48 PM
The READ System Call In UNIX balaIT Linux - General 6 10-30-2010 03:57 PM
Trying to modify read() system call Anduril07 Linux - Newbie 1 05-07-2009 07:01 AM
poll system call in kernel space xatzipol Programming 0 10-16-2005 07:03 AM
Problem using 'read' system call buckles Programming 6 05-10-2005 11:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration