473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to stop bufferring on STDOUT

I am running a program within another and reading the output. My problem
is that all outputs are delayed because of bufferring
Can I tell printf to print all outputs immediately and not buffer it

Thanks
Ram

Nov 14 '05 #1
4 8328
In article <bt************@ID-166953.news.uni-berlin.de>,
Ramprasad A Padmanabhan <ra*******@netcore.co.in> wrote:
I am running a program within another and reading the output. My problem
is that all outputs are delayed because of bufferring
Can I tell printf to print all outputs immediately and not buffer it


You can flush the output buffer of printf(), see:
http://www.eskimo.com/~scs/C-faq/q12.4.html

Regards,
--
Rob van der Leek | rob(at)ricardis(dot)tudelft(dot)nl
Ricardishof 73-A | http://www.ricardis.tudelft.nl/~rob
2614 JE Delft, The Netherlands
+31 (0)6 155 244 60
Nov 14 '05 #2
On Mon, 12 Jan 2004 13:53:17 +0530, Ramprasad A Padmanabhan
<ra*******@netcore.co.in> wrote:
I am running a program within another and reading the output. My problem
is that all outputs are delayed because of bufferring
Can I tell printf to print all outputs immediately and not buffer it


you can make 'stdout' unbuffered by using 'setvbuf()' with _IONBF flag.
For more into see 'man setvbuf'

--
Mohan
Nov 14 '05 #3
"A. J. Mohan Rao" <aj*********@fth7.siemens.de> wrote:
On Mon, 12 Jan 2004 13:53:17 +0530, Ramprasad A Padmanabhan
<ra*******@netcore.co.in> wrote:
I am running a program within another and reading the output. My problem
is that all outputs are delayed because of bufferring

Can I tell printf to print all outputs immediately and not buffer it
you can make 'stdout' unbuffered by using 'setvbuf()' with _IONBF flag.


s/make/try to make/. There's no guarantee that it works. Even when
setvbuf() returns 0 (success), that only means that the C implementation
doesn't buffer stdout any more; the OS still might, and there might be
nothing you can do about it. But yes, setvbuf() is the function to try -
or setbuf(stdout, 0), which amounts to the same thing.
For more into see 'man setvbuf'


Or, indeed, your C book, which is more likely to be ISO-compatible.

Richard
Nov 14 '05 #4
"A. J. Mohan Rao" <aj*********@fth7.siemens.de> wrote:
On Mon, 12 Jan 2004 13:53:17 +0530, Ramprasad A Padmanabhan
<ra*******@netcore.co.in> wrote:
I am running a program within another and reading the output. My problem
is that all outputs are delayed because of bufferring
Can I tell printf to print all outputs immediately and not buffer it


you can make 'stdout' unbuffered by using 'setvbuf()' with _IONBF flag.
For more into see 'man setvbuf'


Well, we're deep in implementation defined land here
[C99 7.19.3#3], so the suggested setvbuf call might
fail on some implementations.

Regards
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc : http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list : http://www.eskimo.com/~scs/C-faq/top.html
acllc-c++ faq : http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html

Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: shyren | last post by:
Hi All, I have a php program which calls a c++ program using exec. However when user presses stop button in the browser or closes it this program keeps on running on the server. How can I stop it...
3
by: dh | last post by:
Runtime.getRuntime().exec() ... mad buffering of stdout ... It buffers stdout without limit ... so if your Java program doesn't keep up with the Process output then memory fills up! I wish it...
10
by: hokiegal99 | last post by:
How can I make this script run w/o seeing a cmd popup window on the screen? The script works well, but each hour (when the task scheduler runs it) a brief cmd window appears and then goes away....
0
by: BS | last post by:
Hi All, This may be an old question, but there's little useful references online that I've been able to find. I want the following code to display bit by bit, not send all at once to the...
4
by: midday.hu | last post by:
Hi, Does someone know how to stop "the information output on screen"? Now when I run my code, it outputs a lot of message when calling other libraries, together with the info with the print...
3
by: SS | last post by:
It seems that my code locks my machine up after the " fclose(datafile);" command I guess I'm not following the next bit of code on properly. Can someone help me out?? SS...
30
by: siliconwafer | last post by:
Hi All, I want to know tht how can one Stop reading a file in C (e.g a Hex file)with no 'EOF'?
9
by: Santtu Nyrhinen | last post by:
Hi, Let say that I have a function like void writeHello() { printf("Hello"); } Now I need to make an automated test fot that function. The test function returns 1 for successful and 0 for...
2
by: CC | last post by:
Hi: I've conjured up the idea of building a hex line editor as a first real Python programming exercise. To begin figuring out how to display a line of data as two-digit hex bytes, I created...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.