/* Build with $ cc -Wall -O2 -fPIC -shared -o libfix_wl_display_flush.so fix_wl_display_flush.c Use as $ LD_PRELOAD=libfix_wl_display_flush.so ./app */ #define _GNU_SOURCE #include #include #include #include #include #include typedef int (*wl_display_flush_t)(struct wl_display*); int wl_display_flush(struct wl_display* d) { static wl_display_flush_t orig_wl_display_flush = NULL; if (!orig_wl_display_flush) { orig_wl_display_flush = (wl_display_flush_t)dlsym(RTLD_NEXT, "wl_display_flush"); if (!orig_wl_display_flush) { fprintf(stderr, "Failed to get wl_display_flush(): %s\n", dlerror()); exit(127); } } int rc = orig_wl_display_flush(d); if (rc < 0) { if (errno == EAGAIN) { usleep(100000); rc = orig_wl_display_flush(d); } } return rc; }