summaryrefslogtreecommitdiff
path: root/libgps_core.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-12-09 17:40:21 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-12-09 17:40:21 +0000
commitffc9a8211892180895015a5f16189138c0927368 (patch)
treeaf34ce2e7008781e5cc7cc3bbe9e08ce65267f79 /libgps_core.c
parentac835718102d12c5849b612c293ca08bc27b5284 (diff)
downloadgpsd-ffc9a8211892180895015a5f16189138c0927368.tar.gz
Add POLL_NONBLOCK flag to the C API. Document all flags.
Diffstat (limited to 'libgps_core.c')
-rw-r--r--libgps_core.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libgps_core.c b/libgps_core.c
index 4abf9890..a3b14cb5 100644
--- a/libgps_core.c
+++ b/libgps_core.c
@@ -7,6 +7,7 @@
#endif /* S_SPLINT_S */
#include <sys/types.h>
#include <stdlib.h>
+#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
@@ -632,7 +633,7 @@ int gps_poll(struct gps_data_t *gpsdata)
0);
if (status > -1)
priv->waiting += status;
- else if (errno == EINTR)
+ else if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
return 0;
else if (priv->waiting == 0)
return status;
@@ -688,6 +689,8 @@ int gps_stream(struct gps_data_t *gpsdata,
else
flags |= WATCH_OLDSTYLE;
}
+ if (flags & POLL_NONBLOCK)
+ (void)fcntl(gpsdata->gps_fd, F_SETFL, O_NONBLOCK);
if ((flags & WATCH_DISABLE) != 0) {
if ((flags & WATCH_OLDSTYLE) != 0) {
(void)strlcpy(buf, "w-", sizeof(buf));