[PATCH] D45636: Make InterruptHandler non-blocking for Fuchsia

Aaron Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 18 15:52:54 PDT 2018


aarongreen updated this revision to Diff 143021.
aarongreen added a comment.

I believe this should be the squashed diff phosek requested.


https://reviews.llvm.org/D45636

Files:
  lib/fuzzer/FuzzerUtilFuchsia.cpp


Index: lib/fuzzer/FuzzerUtilFuchsia.cpp
===================================================================
--- lib/fuzzer/FuzzerUtilFuchsia.cpp
+++ lib/fuzzer/FuzzerUtilFuchsia.cpp
@@ -45,8 +45,13 @@
 }
 
 void InterruptHandler() {
+  fd_set readfds;
   // Ctrl-C sends ETX in Zircon.
-  while (getchar() != 0x03);
+  do {
+    FD_ZERO(&readfds);
+    FD_SET(STDIN_FILENO, &readfds);
+    select(STDIN_FILENO + 1, &readfds, nullptr, nullptr, nullptr);
+  } while(!FD_ISSET(STDIN_FILENO, &readfds) || getchar() != 0x03);
   Fuzzer::StaticInterruptCallback();
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45636.143021.patch
Type: text/x-patch
Size: 564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180418/237a720c/attachment.bin>


More information about the llvm-commits mailing list