From 1467a240901544bf0fdb446f4cd4726a9346891f Mon Sep 17 00:00:00 2001 From: Kian Karas Date: Thu, 4 Oct 2018 13:17:51 +0200 Subject: gpsctl: fix busy loop waiting for device Signed-off-by: Gary E. Miller --- gpsctl.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gpsctl.c') diff --git a/gpsctl.c b/gpsctl.c index 57fb4693..737a30e2 100644 --- a/gpsctl.c +++ b/gpsctl.c @@ -436,6 +436,12 @@ int main(int argc, char **argv) } while (devcount > 0) { + /* Wait for input data */ + if (!gps_waiting(&gpsdata, timeout * 1000000)) { + gpsd_log(&context.errout, LOG_ERROR, "timed out waiting for device\n"); + (void)gps_close(&gpsdata); + exit(EXIT_FAILURE); + } errno = 0; if (gps_read(&gpsdata, NULL, 0) == -1) { gpsd_log(&context.errout, LOG_ERROR, "data read failed.\n"); -- cgit v1.2.1