]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: use poll() on macOS
authorPádraig Brady <P@draigBrady.com>
Sun, 28 Aug 2022 01:32:34 +0000 (02:32 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 29 Aug 2022 14:32:54 +0000 (15:32 +0100)
* src/tail.c (check_output_alive): poll() is the most commonly used
interface, so use this on macOS also to minimize divergence.

src/tail.c

index a4a590a7936ad7ce3342bdeefa8dcb62d41b3fdd..3ae6baf5230353e8fc97ae528e4674472903726a 100644 (file)
@@ -352,14 +352,15 @@ check_output_alive (void)
   if (! monitor_output)
     return;
 
-  /* Use 'poll' on AIX (where 'select' was seen to give a readable
-     event immediately) or if using inotify (which relies on 'poll'
-     anyway).  Otherwise, use 'select' as it's more portable;
-     'poll' doesn't work for this application on macOS.  */
-#if defined _AIX || defined __sun || HAVE_INOTIFY
+  /* poll(2) is needed on AIX (where 'select' gives a readable
+     event immediately) and Solaris (where 'select' never gave
+     a readable event).  Also use poll(2) on systems we know work
+     and/or are already using poll (inotify).  */
+#if defined _AIX || defined __sun || defined __APPLE__ || HAVE_INOTIFY
   struct pollfd pfd;
   pfd.fd = STDOUT_FILENO;
   pfd.events = pfd.revents = 0;
+  pfd.events |= POLLRDBAND; /* Needed for illumos, macos.  */
 
   if (poll (&pfd, 1, 0) >= 0 && (pfd.revents & (POLLERR | POLLHUP)))
     die_pipe ();