How to do a non-blocking write of more than one char?

brnstnd at stealth.acf.nyu.edu brnstnd at stealth.acf.nyu.edu
Thu Jan 11 09:23:33 AEST 1990


In article <2799 at auspex.auspex.com> guy at auspex.auspex.com (Guy Harris) writes:
> It's
> guaranteed that you can write *some* amount of data without blocking,
> but no guarantee as to how much is made, in general.

Can you show me a program that blocks on a write() after select() has
indicated that the descriptor is writable? (select() on this machine
is slightly buggy, so I'm not sure my tests are accurate.)

> Sorry, but you
> really *are* expected to use non-blocking I/O in that case.... 

Okay, Guy, tell me how I accomplish this: Process A writes data to a
pipe connected to Process B. Process A must not block on its writes,
because it has to handle other descriptors as well. Process B is an
already-written program that assumes that its reads are non-blocking;
it'll take EWOULDBLOCK as a read error and die horribly.

Process A can avoid blocking by using select() and writing just one
character at a time. Is there any other way?

C'mon, guys, this is a simple question!

---Dan



More information about the Comp.unix.questions mailing list