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)
Date: Tue, 17 Aug 2004 08:51:38 +0530	[thread overview]
Message-ID: <412179C2.5010003@sancharnet.in> (raw)
In-Reply-To: <20040816144752.43149.qmail@web12701.mail.yahoo.com>

Hossein Mobahi wrote:

>
>The problem is that prg1 does not produce any return
>(I mean '\n'), and numbers are separated by space.
>Therefore, read(fd,n,buf) blocks even if "n" is
>smaller than what prg1 has actually written to the
>pipe (no matter what n is, even if the pipe's buffer
>contains more characters than n, read first waits for
>return and onces gets it, it will copy n bytes of the
>buffer to buf). On the other hand opening in
>  
>
Funny. I have used read() to get 2 characters out of a binary file with 
no "\n"'s
and it never behaved like this. Also the man page make sno mention of 
this either.
Did you try this out? How about fread/fwrite?

Joy.M.Monteiro

>non-blocking fashion doesn't help, because I want my
>program to wait for the output of prg1. Is there any
>way to make read() return once the pipe has more
>characters than n? What about defining another
>delimiter such as "blank", instead of "return"? Let me
>add that I do not want to touch kernel sources, I am
>looking for a more portable solution using available
>system calls or shell's capabilities.
>
>Thnx
>
>--Hossein
>
>
>  
>


  parent reply	other threads:[~2004-08-17  3:21 UTC|newest]

Thread overview: 8+ 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 ` joy [this message]
2004-08-17 10:55   ` Problem with read() and named pipe (FIFO) (pipe not disk) Hossein Mobahi
2004-08-17 17:58     ` joy
2004-08-17 19:24       ` Hossein Mobahi
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=412179C2.5010003@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).