linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: joy <gracecott@sancharnet.in>
To: Hossein Mobahi <hmobahi@yahoo.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Problem with read() and named pipe (FIFO) (pipe not disk)
Date: Tue, 17 Aug 2004 23:28:15 +0530	[thread overview]
Message-ID: <41224737.9010006@sancharnet.in> (raw)
In-Reply-To: <20040817105504.31840.qmail@web12706.mail.yahoo.com>

Hossein Mobahi wrote:

>Hello
>
>The problem is not "\n", but buffered I/O used by
>standard IO library. I head that sometimes "\n"
>flushes the buffer, but it did not (as I am
>experiencing now).
>
>You did not have any problem, because you were
>directly reading from a file. If you were reading from
>STDIN_FILENO, you would not get your characters when
>using "./prg1 | ./prg2" where prg1 is:
>main() { printf("TEST\n"); for (;;); }
>
>and prg2 is:
>main() { read(STDIN_FILENO, buf, 1000); printf
>("%s\n",buf) ; }
>
>The solution that I know is using
>write(STDOUT_FILENO,....) instead of printf because it
>does not buffer. However, I do not have access to the
>source code of prg1, and I must somehow make prg1
>flush its standard I/O buffer from outside.
>
>  
>
The program cannot buffer data for all eternity and must eventually 
write it to the
pipe. So, even if read() blocks because  there is no data available, it 
must return as soon as data
is written. The real-time element will be lost though I doubt it will 
buffer for a long time.
Is this the behavior you are experiencing and is there a problem with this ?

Joy.M.Monteiro

  reply	other threads:[~2004-08-17 17:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-16 14:47 Problem with read() and named pipe (FIFO) Hossein Mobahi
2004-08-16 14:57 ` Henry Margies
2004-08-17 10:58   ` Problem with read() and named pipe (FIFO) (fflush or fsync) Hossein Mobahi
2004-08-17  3:21 ` Problem with read() and named pipe (FIFO) joy
2004-08-17 10:55   ` Problem with read() and named pipe (FIFO) (pipe not disk) Hossein Mobahi
2004-08-17 17:58     ` joy [this message]
2004-08-17 19:24       ` Hossein Mobahi
2004-08-17 19:25       ` Hossein Mobahi
  -- strict thread matches above, loose matches on Subject: below --
2004-08-17 19:25 Hossein Mobahi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41224737.9010006@sancharnet.in \
    --to=gracecott@sancharnet.in \
    --cc=hmobahi@yahoo.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).