summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 03e31c0)
raw | patch | inline | side by side (parent: 03e31c0)
author | octo <octo> | |
Sat, 10 Jun 2006 12:59:43 +0000 (12:59 +0000) | ||
committer | octo <octo> | |
Sat, 10 Jun 2006 12:59:43 +0000 (12:59 +0000) |
If `sread' receives an EOF it will now close the file descriptor and return an
error. Prior to this revision it would try to read again and possibly fail
then.. Alternatively it might have crashed, who knows..? ;)
error. Prior to this revision it would try to read again and possibly fail
then.. Alternatively it might have crashed, who knows..? ;)
src/common.c | patch | blob | history | |
src/common.h | patch | blob | history |
diff --git a/src/common.c b/src/common.c
index 98e670443810b844a9dcc2f47615fc23921556a9..5487b326fd34ac31eb8adfe20fa6971ecd0c4fec 100644 (file)
--- a/src/common.c
+++ b/src/common.c
if (status < 0)
return (status);
+ if (status == 0)
+ {
+ DBG ("Received EOF from fd %i. "
+ "Closing fd and returning error.",
+ fd);
+ close (fd);
+ return (-1);
+ }
+
assert (nleft >= status);
nleft = nleft - status;
diff --git a/src/common.h b/src/common.h
index f6a8e19a68843b71acec79896d5592dc41e244ad..2be2ff504b84f58276bc3304ef5696c5623ec52d 100644 (file)
--- a/src/common.h
+++ b/src/common.h
*
* DESCRIPTION
* Reads exactly `n' bytes or failes. Syntax and other behavior is analogous
- * to `read(2)'.
+ * to `read(2)'. If EOF is received the file descriptor is closed and an
+ * error is returned.
*
* PARAMETERS
* `fd' File descriptor to write to.