serial2mqtt icon indicating copy to clipboard operation
serial2mqtt copied to clipboard

the sleep(UINT32_MAX) has exited on OpenWRT instantly

Open halfbakery opened this issue 4 years ago • 2 comments

The sleep(UINT32_MAX) has exited instantly on OpenWrt. This fix will work forever :-)

halfbakery avatar May 13 '21 22:05 halfbakery

I forgot to mention, that sleep(INT32_MAX) is working correctly, only the greater values are problematic. It's definetly not a busy loop. The for loop around the sleep is just some extra pedantry:

  • serial2mqtt could run longer than than 68 years :-)
  • theoretically signal handlers could interrupt sleep (currently we don't use signal handlers, but this solution is future proof)

If you have any concerns, please let me know.

halfbakery avatar May 16 '21 10:05 halfbakery

Or we can use a more idiomatic way:

for (;;)
{
    pause();
}

halfbakery avatar May 17 '21 09:05 halfbakery