Date: Fri, 23 Feb 1996 11:47:31 -0800 (GMT) From: Orlando Andico 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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.