summaryrefslogtreecommitdiff
path: root/gpspipe.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-12-03 00:18:22 -0500
committerEric S. Raymond <esr@thyrsus.com>2010-12-03 00:18:22 -0500
commit28ff7510067a5609bc6eec1c4f9ec178488dadf5 (patch)
tree044494429aaa66006865cac014c81394adefd039 /gpspipe.c
parent07c982702b1fdcf79d24d4411a71297595c0d14b (diff)
downloadgpsd-28ff7510067a5609bc6eec1c4f9ec178488dadf5.tar.gz
Attempt to address #17564: gpspipe terminates because of non-blocking socket.
Diffstat (limited to 'gpspipe.c')
-rw-r--r--gpspipe.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gpspipe.c b/gpspipe.c
index 5164ac68..be84829c 100644
--- a/gpspipe.c
+++ b/gpspipe.c
@@ -316,6 +316,7 @@ int main(int argc, char **argv)
spinner(vflag, l++);
/* reading directly from the socket avoids decode overhead */
+ errno = 0;
readbytes = (int)read(gpsdata.gps_fd, buf, sizeof(buf));
if (readbytes > 0) {
for (i = 0; i < readbytes; i++) {
@@ -371,7 +372,10 @@ int main(int argc, char **argv)
}
} else {
if (readbytes == -1) {
- (void)fprintf(stderr, "gpspipe: read error %s(%d)\n",
+ if (errno == EAGAIN)
+ continue;
+ else
+ (void)fprintf(stderr, "gpspipe: read error %s(%d)\n",
strerror(errno), errno);
exit(1);
} else {