setvbuf

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • j0mbolar

    setvbuf

    is using _IONBF with setvbf the general way of getting
    an unbuffered stream in a standardized way? or are system
    specific functions generally favored over c89's setvbuf?
  • Jens.Toerring@physik.fu-berlin.de

    #2
    Re: setvbuf

    j0mbolar <j0mbolar@engin eer.com> wrote:[color=blue]
    > is using _IONBF with setvbf the general way of getting
    > an unbuffered stream in a standardized way?[/color]

    Yes.
    [color=blue]
    > or are system specific functions generally favored over c89's
    > setvbuf?[/color]

    Since it unbuffers the standard C functions (i,e, fprintf(),
    fwrite() etc.) there probably isn't a system specific way to
    unbuffer them. But unbuffering the C functions might nor do
    everything you want, the system can do further buffering on
    several levels (e.g. not immediately writing things to a
    file but keeping it in some kernel buffers and even a write
    to a hard disk could again go through some buffers on the
    hard disk), and to switch that off you would need system
    specific functions.
    Regards, Jens
    --
    \ Jens Thoms Toerring ___ Jens.Toerring@p hysik.fu-berlin.de
    \______________ ____________ http://www.toerring.de

    Comment

    • Dan Pop

      #3
      Re: setvbuf

      In <2d31a9f9.04081 91938.4214ae7c@ posting.google. com> j0mbolar@engine er.com (j0mbolar) writes:
      [color=blue]
      >is using _IONBF with setvbf the general way of getting
      >an unbuffered stream in a standardized way? or are system
      >specific functions generally favored over c89's setvbuf?[/color]

      You're confused. There are multiple buffering levels on most hosted
      platforms. setvbuf controls the buffering performed at the level of the
      <stdio.h> functions and there is no other alternative (except for setbuf,
      which is a less flexible setvbuf). The OS itself typically performs its
      own buffering, and this buffering is controlled with system specific
      functions. Some devices also do their own buffering and this buffering
      may not be controllable by the application code.

      This explains why, on many platforms, even if stdin buffering is
      turned off with setvbuf, reading from stdin still blocks until the
      newline key is pressed (assuming that stdin is connected to the
      controlling terminal).

      Dan
      --
      Dan Pop
      DESY Zeuthen, RZ group
      Email: Dan.Pop@ifh.de

      Comment

      Working...