Skip to content

Instantly share code, notes, and snippets.

@Ancurio
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ancurio/ae83d3bacc7991e5ca5b to your computer and use it in GitHub Desktop.
Save Ancurio/ae83d3bacc7991e5ca5b to your computer and use it in GitHub Desktop.
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 01e80c7..300bebb 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -34,6 +34,7 @@
#include "etc-internal.h"
#include "binding.h"
#include "perftimer.h"
+#include "debugwriter.h"
#include <SDL_video.h>
#include <SDL_timer.h>
@@ -41,6 +42,7 @@
#include <time.h>
#include <sys/time.h>
+#include <errno.h>
#include <algorithm>
struct PingPong
@@ -342,8 +344,19 @@ private:
struct timespec req;
req.tv_sec = 0;
req.tv_nsec = ticks / tickFreqNS;
+ errno = 0;
+
while (nanosleep(&req, &req) == -1)
- ;
+ {
+ int err = errno;
+ errno = 0;
+
+ if (err == EINTR)
+ continue;
+
+ Debug() << "nanosleep failed. errno:" << err << "ticks:" << ticks;
+ break;
+ }
#else
SDL_Delay(ticks / tickFreqMS);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment