WaitAnySystemEvent: retry poll if errno=EAGAIN or EINTR.

Bug: b/342945534
Change-Id: I383376c2c3789aa9afe1ef65a6ae20211e7385c0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/190200
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
diff --git a/src/dawn/native/WaitAnySystemEvent.h b/src/dawn/native/WaitAnySystemEvent.h
index 630850d..5777c2e 100644
--- a/src/dawn/native/WaitAnySystemEvent.h
+++ b/src/dawn/native/WaitAnySystemEvent.h
@@ -44,6 +44,7 @@
 #endif
 
 #include "absl/container/inlined_vector.h"
+#include "dawn/common/Log.h"
 #include "dawn/native/SystemEvent.h"
 
 namespace dawn::native {
@@ -100,7 +101,20 @@
     for (auto it = begin; it != end; ++it) {
         pollfds.push_back(pollfd{static_cast<int>((*it).first.mPrimitive.Get()), POLLIN, 0});
     }
-    int status = poll(pollfds.data(), pollfds.size(), ToMilliseconds(timeout));
+    int status;
+    bool retry;
+    do {
+        retry = false;
+        status = poll(pollfds.data(), pollfds.size(), ToMilliseconds(timeout));
+        if (status < 0) {
+            int lErrno = errno;
+            if (EAGAIN == lErrno || EINTR == lErrno) {
+                retry = true;
+            } else {
+                dawn::ErrorLog() << "poll errno=" << lErrno;
+            }
+        }
+    } while (retry);
 
     DAWN_CHECK(status >= 0);
     if (status == 0) {