www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/02/22/23:02:12

Date: Fri, 23 Feb 1996 11:47:31 -0800 (GMT)
From: Orlando Andico <oandico AT eee DOT upd DOT edu DOT ph>
To: j DOT aldrich6 AT genie DOT com
cc: djgpp AT delorie DOT com
Subject: Re: errno question: EWOULDBLOCK
In-Reply-To: <199602230222.AA219862133@relay1.geis.com>
Message-ID: <Pine.SOL.3.91.960223114516.1530A-100000@gollum>
MIME-Version: 1.0

On Fri, 23 Feb 1996 j DOT aldrich6 AT genie DOT com wrote:

> Here's a question for v2:  The errno EWOULDBLOCK, which a
> large program I am working on uses, does not seem to be defined
> in errno.h in v2.  I am not even sure what EWOULDBLOCK is used for - I just
> know that very few C compilers I have tried seem to have any idea what
> it is.  It has something to do with Unix socket i/o - I know that much.  I
> sneaked a peek at the v1 source code and saw that EWOULDBLOCK
> was defined as errno 35, so I substituted the current user of that errno in
> my code, which is ESPIPE.  I don't know if that's what I should be doing
> or not.  Please advise!
> 
> Thanks,
>     John Aldrich
> 

EWOULDBLOCK is the error number returned from a read() or write() which 
*would* block but didn't. For example, if you read from a port which 
isn't ready, your program sleeps ("blocks") until the data comes in. 
However, you can set things up such that the port does *not* block, using 
fcntl() -- although this is for Unix, I don't think it's supported under 
MS-DOG. Anyway, if the port is set up as nonblocking, you read from it, 
and there is nothing there, the read immediately returns with a -1 
(error) but errno == EWOULDBLOCK to tell you the error was caused by 
unavailability of data, not some hardware error.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019