From ffff5d66462e7c7e2f9a6104a01fbf8310ebb681 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 3 Oct 2019 11:16:44 -0700 Subject: [PATCH] treewide: Replace usleep with nanosleep usleep was removed in POSIX 2008 and is optionally unavailable with uClibc-ng. Signed-off-by: Rosen Penev --- dump1090.c | 3 ++- faup1090.c | 3 ++- view1090.c | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dump1090.c b/dump1090.c index b654c01..3b205aa 100644 --- a/dump1090.c +++ b/dump1090.c @@ -660,12 +660,13 @@ int main(int argc, char **argv) { if (Modes.sdr_type == SDR_NONE) { while (!Modes.exit) { struct timespec start_time; + struct timespec slp = { 0, 100 * 1000 * 1000}; start_cpu_timing(&start_time); backgroundTasks(); end_cpu_timing(&start_time, &Modes.stats_current.background_cpu); - usleep(100000); + nanosleep(&slp, NULL); } } else { int watchdogCounter = 10; // about 1 second diff --git a/faup1090.c b/faup1090.c index e476a7e..1232c6a 100644 --- a/faup1090.c +++ b/faup1090.c @@ -207,8 +207,9 @@ int main(int argc, char **argv) { // Run it until we've lost either connection while (!Modes.exit && beast_input->connections && fatsv_output->connections) { + struct timespec r = { 0, 100 * 1000 * 1000}; backgroundTasks(); - usleep(100000); + nanosleep(&r, NULL); } return 0; diff --git a/view1090.c b/view1090.c index 863cc83..b4b8f1b 100644 --- a/view1090.c +++ b/view1090.c @@ -212,6 +212,7 @@ int main(int argc, char **argv) { // Keep going till the user does something that stops us while (!Modes.exit) { + struct timespec r = { 0, 100 * 1000 * 1000}; icaoFilterExpire(); trackPeriodicUpdate(); modesNetPeriodicWork(); @@ -221,12 +222,12 @@ int main(int argc, char **argv) { if (s->connections == 0) { // lost input connection, try to reconnect - usleep(1000000); + sleep(1); c = serviceConnect(s, bo_connect_ipaddr, bo_connect_port); continue; } - usleep(100000); + nanosleep(&r, NULL); } interactiveCleanup();