fwrite over pipes question

This is a discussion on fwrite over pipes question within the Linux Programming forums, part of the Platform Specific Boards category; I was told that if I used fprint or fwrite to output to the parent-to-child command pipeline, it might not ...

  1. #1
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329

    fwrite over pipes question

    I was told that if I used fprint or fwrite to output to the parent-to-child command pipeline, it might not be on the actual pipe when I do a read of the child.

    How can this happen? Can someone give me an example?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    Well there might be a timing issue, but whatever you write should be read eventually.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    How could there be a timing issue with fwrite() and not with write()?

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    fwrite() is buffered because it uses stdio. write() is a system call that directly writes to the file in question via the file descriptor, and not a FILE object via its buffer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. Question about reading from pipes.
    By Ironic in forum C Programming
    Replies: 7
    Last Post: 11-30-2008, 10:19 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Services and Pipes
    By nickname_changed in forum Windows Programming
    Replies: 0
    Last Post: 07-16-2003, 06:46 AM
  5. fwrite question
    By fkheng in forum C Programming
    Replies: 3
    Last Post: 07-12-2003, 04:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21