*BSD News Article 79499


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!spool.mu.edu!howland.erols.net!news.mathworks.com!newsfeed.internetmci.com!in3.uu.net!news.artisoft.com!usenet
From: Terry Lambert <terry@lambert.org>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Blocking with pipes.
Date: Sun, 29 Sep 1996 16:25:18 -0700
Organization: Me
Lines: 22
Message-ID: <324F055E.23DCD26D@lambert.org>
References: <52k448$sjj@herald.concentric.net>
NNTP-Posting-Host: hecate.artisoft.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.01 (X11; I; Linux 1.1.76 i486)

Andrew Verba wrote:
]         while(read(fd[0],string,50) > 0 ) {
]                 do something with string;
]         }

[ ... ]
 
] Why does this read some of the input from the executing file
] and then hang (block) ?

Because you use stdio in the writer program, and output is not
flushed automatically?

Note: if you are using gets()/etc. to read to imply a flush,
you should be aware that implie flush only functions on tty
devices, not pipes (see the man page, see POSIX, see ANSI).

                                        Terry Lambert
                                        terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.