GNU bug report logs -
#11620
libc I/O buffers not flushed confusion
Previous Next
Reported by: vikas bansal <vikasbansal27 <at> gmail.com>
Date: Sun, 3 Jun 2012 17:56:02 UTC
Severity: normal
Tags: notabug
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11620 in the body.
You can then email your comments to 11620 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#11620
; Package
coreutils
.
(Sun, 03 Jun 2012 17:56:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
vikas bansal <vikasbansal27 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Sun, 03 Jun 2012 17:56:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The sleep function when written at the end, forces the program to sleep,
preventing him to execute any printf() instructions before it.
Attaching a program.
--
Vikas Bansal
Student(ECE undergraduate final year)
The L.N.Mittal Institute of Information Technology,Rajasthan,India.
[Message part 2 (text/html, inline)]
[process1.c (text/x-csrc, attachment)]
Reply sent
to
Pádraig Brady <P <at> draigBrady.com>
:
You have taken responsibility.
(Sun, 03 Jun 2012 20:38:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
vikas bansal <vikasbansal27 <at> gmail.com>
:
bug acknowledged by developer.
(Sun, 03 Jun 2012 20:38:01 GMT)
Full text and
rfc822 format available.
Message #10 received at 11620-done <at> debbugs.gnu.org (full text, mbox):
tag 11620 notabug
On 06/03/2012 01:13 PM, vikas bansal wrote:
> The sleep function when written at the end, forces the program to sleep,
> preventing him to execute any printf() instructions before it.
> Attaching a program.
You got the wrong list because you followed `man 1 sleep`
rather than `man 3 sleep`.
I've not looked at the program at all,
but you may need to add some fflush(stdout) calls,
to ensure timely output.
cheers,
Pádraig.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#11620
; Package
coreutils
.
(Sun, 03 Jun 2012 20:40:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 11620 <at> debbugs.gnu.org (full text, mbox):
retitle 11620 libc I/O buffers not flushed confusion
tag 11620 + notabug
close 11620
thanks
vikas bansal wrote:
> The sleep function when written at the end, forces the program to sleep,
> preventing him to execute any printf() instructions before it.
You have confused the sleep(3) libc C library routine with the
coreutils sleep(1) command line utility.
Please see this reference:
http://www.gnu.org/software/coreutils/faq/#I-am-trying-to-compile-a-C-program-_002e_002e_002e
> Attaching a program.
Thank you for showing us the program even if it isn't anything to do
with coreutils.
> printf("going to sleep");
Missing "\n" newline at end of line?
> while (*shm != '*')
> sleep(1);
> exit(0);
The misunderstanding you are seeing is that printf() is calling the
libc stdio function which is buffering the output data. This data is
only flushed when exit() is called. The libc buffers data differently
depending upon the context of the file such as if the output is a tty
or a file.
If you wish to ensure that data is output then you should fflush() the
data in the libc I/O buffers.
http://pubs.opengroup.org/onlinepubs/009696799/functions/fflush.html
Bob
Changed bug title to 'libc I/O buffers not flushed confusion' from 'Bug in sleep--linux 2.6'
Request was from
Bob Proulx <bob <at> proulx.com>
to
control <at> debbugs.gnu.org
.
(Sun, 03 Jun 2012 20:41:01 GMT)
Full text and
rfc822 format available.
Added tag(s) notabug.
Request was from
Bob Proulx <bob <at> proulx.com>
to
control <at> debbugs.gnu.org
.
(Sun, 03 Jun 2012 20:41:01 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 02 Jul 2012 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 40 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.