diff options
author | Beat Bolli <bbolli@ewanet.ch> | 2011-03-12 23:49:27 +0100 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-03-12 17:51:05 -0500 |
commit | 51d0b210e010ab1a30c1329d097cff08562aaf94 (patch) | |
tree | 76bf4d345f20b7de3ca7be0313b9088425bc521f /cgps.c | |
parent | b314d0fc177918edcb221137bd544b562299c8cf (diff) | |
download | gpsd-51d0b210e010ab1a30c1329d097cff08562aaf94.tar.gz |
Don't let cgps leave the terminal in a bad state on timeout.
Exit()ing on timeout leaves the terminal in noecho state, so
we have to undo the curses initialization on timeout.
Signed-off-by: Eric S. Raymond <esr@thyrsus.com>
Diffstat (limited to 'cgps.c')
-rw-r--r-- | cgps.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -129,6 +129,7 @@ static bool compass_flag = false; #define CGPS_QUIT 0 /* voluntary yterminastion */ #define GPS_GONE -1 /* GPS device went away */ #define GPS_ERROR -2 /* low-level failure in GPS read */ +#define GPS_TIMEOUT -3 /* low-level failure in GPS waiting */ /* Convert true heading to magnetic. Taken from the Aviation Formulary v1.43. Valid to within two degrees within the @@ -225,6 +226,9 @@ static void die(int sig) case GPS_ERROR: (void)fprintf(stderr, "cgps: GPS read returned error\n"); break; + case GPS_TIMEOUT: + (void)fprintf(stderr, "cgps: GPS timeout\n"); + break; default: (void)fprintf(stderr, "cgps: caught signal %d\n", sig); break; @@ -857,8 +861,7 @@ int main(int argc, char *argv[]) /* heart of the client */ for (;;) { if (!gps_waiting(&gpsdata, 5000000)) { - fprintf(stderr, "cgps: error while waiting\n"); - exit(2); + die(GPS_TIMEOUT); } else { errno = 0; if (gps_read(&gpsdata) == -1) { |