Code

sensors plugin: Improved the documentation in the sample configfile and the `collectd...
[collectd.git] / src / common.c
index 138b7678cf3767fc7c3a6f551e86842ac3176b84..5487b326fd34ac31eb8adfe20fa6971ecd0c4fec 100644 (file)
@@ -144,6 +144,15 @@ ssize_t sread (int fd, void *buf, size_t count)
                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;
@@ -161,7 +170,7 @@ ssize_t swrite (int fd, const void *buf, size_t count)
        ssize_t     status;
 
        ptr   = (const char *) buf;
-       nleft = buflen;
+       nleft = count;
 
        while (nleft > 0)
        {