473,473 Members | 2,286 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 8333
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: 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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.