bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#12975: A puzzling issue with "tee".


From: Bob Proulx
Subject: bug#12975: A puzzling issue with "tee".
Date: Fri, 23 Nov 2012 15:50:05 -0700
User-agent: Mutt/1.5.21 (2010-09-15)

tag 12975 + notabug
close 12975
thanks

liyu wrote:
> There is a issue puzzling me.

We welcome your discussion but in the future please post discussion
questions to address@hidden and not to the bug tracker.  Thanks.

> When I use the "tee" command, the log of a.out will lose if I use
> "ctrl+c" to kill it.

Thank you for posting the details of your question with all of the
steps needed to reproduce the issue.  It helps a lot and most people
don't do as well with it.

> In step (3), before 6 sec input "ctrl + c", the log will lose.
> I want to know how to let the log collect real-timely.

You are running into libc stdio buffering.  Normally the libc stdio
called through printf(3) will collect up output and then output it all
at once, if the output device is not a terminal device.  This improves
performance for most applications.  But since you are piping the
output to tee the output is buffered and it is still in the memory of
your program.  When you interrupt it with SIGINT via control-C the
program exits and never writes the buffer to the output.  This doesn't
have anything to do with tee but is all within the component of your
program that is writing the output.

Rather than go into all of the details in this email let me point you
to a nice web page with much discussion about exactly this issue.
Please read through this.

  http://www.pixelbeat.org/programming/stdio_buffering/

Please let us know if this answers your questions.  Just group
follow-up reply-all to this message so as to keep the bug log in the
recipient list.

Bob





reply via email to

[Prev in Thread] Current Thread [Next in Thread]