LinuxQuestions.org
Review your favorite Linux distribution.
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 07-12-2005, 05:47 PM   #1
Elric of Grans
Member
 
Registered: May 2005
Posts: 46

Rep: Reputation: 15
flush() before use...


G'Day,

I am working on a Linux device driver, and have already implimented the basic open(), read(), write() and close() function. The next thing I need to add is a flush() operation, as there are several things that need to be reinitialised between tasks. I think I know what to do on the kernel side of things, but I actually do not know what the flush command is! There does not seem to be an actual `int flush(int fd)' function (at least, there is no man page for it on my system), so I guess the function is named something else.

Simple question, really: what is the C function that falls the flush() operation from a device driver?
 
Old 07-12-2005, 07:54 PM   #2
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: LFS-Version SVN-20091202, Arch 2009.08
Posts: 1,485

Rep: Reputation: 66
here is an excerpt from the gnu c programming tutorial for fflush im sure flush is similar tho.

Quote:
Having stdin and stdout be line-buffered is convenient, because most meaningful chunks of data you write to them are terminated with a newline character. In order to ensure that the data you read from or write to a fully-buffered stream shows up right away, use the fflush function. In the jargon, this is called flushing the stream. Flushing moves the characters from the buffer to the file, if they haven't already been moved. After the move, other functions can then work on the characters.1

To use fflush, simply pass the function the stream you want to flush. The fflush function returns 0 if successful, or the value EOF (which is a macro defined in the GNU C Library) if there was a write error.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
ARP flush abneru Suse/Novell 3 01-27-2012 12:57 PM
flush my server logs? mikz Linux - Security 1 03-14-2005 05:34 AM
How do I flush a C++ socket? pjz Programming 5 02-25-2005 10:55 AM
How can i flush iptables?? cranium2004 Linux - Networking 2 01-06-2005 02:08 PM
C flush() question ...... purpleburple Programming 3 11-15-2002 09:27 AM


All times are GMT -5. The time now is 08:11 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration