Find the answer to your Linux question:
Results 1 to 8 of 8
As everyone knows, stdout is buffered and stderr is UNbuffered. What I would like to know is, how big is the stream buffer for input and output? I suspect that ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319

    stream buffer size


    As everyone knows, stdout is buffered and stderr is UNbuffered. What I would like to know is, how big is the stream buffer for input and output? I suspect that this may be machine dependent and this really is useless knowledge but I'm rather curious to find out more about this.

    bp
    The best things in life are free.

  2. #2
    Linux User
    Join Date
    Jul 2002
    Location
    Daytona Beach, FL
    Posts
    487
    off the top of my head i dont recall, but STDIN is easy to figure out(sort of) - hold down a key until it stops repeating, count the # of times your key appeared -this will give you the size of the terminal buffer - however this is seperate from the stdio buffering
    majorwoo

    Quiet brain, or I\'ll stab you with a Q-tip.

  3. #3
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    This, as majorwoo pointed out, depends on whether you refer to stdio buffering or terminal buffering. stdout, stderr and stdin aren't buffered at all in stdio, I think, but the terminal buffers input until either the EOF key is pressed or a newline is received on the terminal. This can be reconfigured with stty or the appropriate ioctl's, of course. See stty(1) or termios(3). stdout and stderr aren't buffered at all by default. That might be system dependent, though, eg. if the distribution does some reconfiguring.
    The stdio buffering is configurable with the setbuf family of calls (see setbuf(3) or stdio(3)).

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Nov 2002
    Location
    USA
    Posts
    99
    Are you referring to the iostream buffers used in C++? If so, they have yet another buffer size. The buffer size may be machine or compiler specific. Best place to look for that is the source code!

  6. #5
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Sorry, I was wrong. stdout, ie. the stdio FILE *stdout, is line buffered, ie. it's automatically flushed whenever a newline is sent to it. As I mentioned, though, this can be reconfigured with setbuf(3) if that's desirable. fd 1 is, of course, not buffered at all. Istus est: fprintf(stdout, "a"); needs to be flushed, while fprintf(stdout, "a\n"); flushes itself. write(1, "a", 1); on the other hand outputs an "a" without a newline. I'm assuming that the same goes for FILE *stderr and fd 2.
    Just to clarify from my last post, fd 0 isn't buffered in itself, but the kernel's standard line discipline buffers the user's input data from the master tty device (the keyboard, /dev/ptmx, etc.) before it is actually received by fd 0. This is reconfigurable with tcsetattr(3) or stty(1) (see the icanon flag to stty or the ICANON bit in c_lflag to tcsetattr). The stdio FILE *stdin is unbuffered. That can also be reconfigured with setbuf(3), of course.

  7. #6
    Linux User
    Join Date
    Jul 2002
    Location
    Daytona Beach, FL
    Posts
    487
    one of the best things about linux is that nowhere in there did we use that words

    "oh, well that's a _feature_ and you can't change that"
    majorwoo

    Quiet brain, or I\'ll stab you with a Q-tip.

  8. #7
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    My opinion exactly. That is what makes linux (unix) and open source so great, together with the fact that _everything_ is debuggable. I was recently asked by a local school to fix a problem with their IIS server (the IDC extension to be more exact), and it's just impossible, since it generates no debug logs, it's not debuggable with any tool for less than $1000, there's no source code, and the error message you get is "internal server error" with not even a reference to what subsystem generated that error. How is anyone supposed to get anything done with a system like that?! With linux and apache, the worst thing I'd ever have to do would be to resort to downloading the source and gdb'ing it. And that's having gone far.

  9. #8
    Linux User
    Join Date
    Jul 2002
    Location
    Daytona Beach, FL
    Posts
    487
    but your supposed to pay a microsoft certified person $250/hr to come check it out for you.. which basically amounts to looking through his book that he paid 5k for to finally say

    "oh, well that's a _feature_ and you can't change that"

    so I'm a vindictive ba*tard - so what?
    majorwoo

    Quiet brain, or I\'ll stab you with a Q-tip.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •