From 39ee4121a1e921dd1dd23d05eb641f7f9174172b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 6 Aug 2016 06:19:41 +0200 Subject: [PATCH] darwin: handle EINTR in /dev/tty workaround MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On OS X, special files like /dev/null and /dev/tty don't work with kqueue. Libuv falls back to select() in that case but the initial probe didn't handle EINTR. Introduced in August 2012 in commit 731adaca ("unix: use select() for specific fds on OS X"), this bug was only ten days away from celebrating its fourth birthday. PR-URL: https://github.com/libuv/libuv/pull/979 Reviewed-By: Colin Ihrig Reviewed-By: Saúl Ibarra Corretgé --- src/unix/stream.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/unix/stream.c b/src/unix/stream.c index 2143cd88..d0c2f1ad 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -291,7 +291,10 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) { timeout.tv_sec = 0; timeout.tv_nsec = 1; - ret = kevent(kq, filter, 1, events, 1, &timeout); + do + ret = kevent(kq, filter, 1, events, 1, &timeout); + while (ret == -1 && errno == EINTR); + uv__close(kq); if (ret == -1)