From b141d9bcc8b5a4647e3c5f106115c8bf5a67f6cd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 18 Jun 2012 22:02:57 +0000 Subject: retry interrupted kevent calls Many thanks to geekosaur in #haskell for help with this. --- Utility/libkqueue.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Utility') diff --git a/Utility/libkqueue.c b/Utility/libkqueue.c index cc001045b..5b38cdd33 100644 --- a/Utility/libkqueue.c +++ b/Utility/libkqueue.c @@ -12,6 +12,7 @@ #include #include #include +#include /* The specified fds are added to the set of fds being watched for changes. * Fds passed to prior calls still take effect, so it's most efficient to @@ -30,7 +31,11 @@ signed int helper(const int kq, const int fdcnt, const int *fdlist, 0, 0); } - nev = kevent(kq, chlist, fdcnt, evlist, 1, timeout); + while ((nev = kevent(kq, chlist, fdcnt, evlist, 1, timeout))) { + if (!(nev == -1 && errno == EINTR)) { + break; + } + } if (nev == 1) return evlist[0].ident; -- cgit v1.2.3