]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
* bootstrap.conf (gnulib_modules): Add isapipe.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 29 Aug 2006 20:50:21 +0000 (20:50 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 29 Aug 2006 20:50:21 +0000 (20:50 +0000)
* src/tail.c: Include isapipe.h.
(IS_PIPE_LIKE_FILE_TYPE): Remove.
(IS_TAILABLE_FILE_TYPE): Just list both FIFOs and sockets as
tailable, since this seems to be portable.
(main): Use isapipe, to fix a bug on MacOS X reported by Bruno Haible in
<http://lists.gnu.org/archive/html/bug-coreutils/2006-08/msg00304.html>.

ChangeLog
bootstrap.conf
src/tail.c

index ca4d15d20ae5640218e24fbcbed3d840ffabdb09..c3470034ab6c897cf262d651dbe48565a1dc62b4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2006-08-29  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * bootstrap.conf (gnulib_modules): Add isapipe.
+       * src/tail.c: Include isapipe.h.
+       (IS_PIPE_LIKE_FILE_TYPE): Remove.
+       (IS_TAILABLE_FILE_TYPE): Just list both FIFOs and sockets as
+       tailable, since this seems to be portable.
+       (main): Use isapipe, to fix a bug on MacOS X reported by Bruno Haible in
+       <http://lists.gnu.org/archive/html/bug-coreutils/2006-08/msg00304.html>.
+
        * src/system.h (LOCALEDIR): Remove, since configmake.h now defines
        it for us.
 
index 48e5d047b0551896266b7a3972e1085df78f6021..8c2c8974dd918d3441c6bd1ba0e5c50d553c3145 100644 (file)
@@ -47,7 +47,8 @@ gnulib_modules="
        getline getloadavg getndelim2 getopt getpagesize getpass-gnu
        gettext gettime gettimeofday getugroups getusershell gnupload
        group-member hard-locale hash hash-pjw host-os human idcache
-       inttostr inttypes lchmod lchown lib-ignore linebuffer link-follow
+       inttostr inttypes isapipe
+       lchmod lchown lib-ignore linebuffer link-follow
        long-options lstat malloc mbswidth md5 memcasecmp mempcpy
        memrchr mkancesdirs mkdir mkdir-p mkstemp mktime modechange
        mountlist obstack pathmax perl physmem posixtm posixver putenv
index 767e0e75bd6b42bff058cc735263798f1d660336..082ddfc5217374b1f1cc28d340e506f6bebe1e29 100644 (file)
@@ -37,6 +37,7 @@
 #include "error.h"
 #include "fcntl--.h"
 #include "inttostr.h"
+#include "isapipe.h"
 #include "posixver.h"
 #include "quote.h"
 #include "safe-read.h"
@@ -74,14 +75,9 @@ enum Follow_mode
   Follow_descriptor = 2
 };
 
-/* On Darwin 7.7, when reading from a command-line pipe, standard
-   input is of type S_ISSOCK.  Everywhere else it's S_ISFIFO.  */
-#define IS_PIPE_LIKE_FILE_TYPE(Mode) \
-  (S_ISFIFO (Mode) || S_ISSOCK (Mode))
-
 /* The types of files for which tail works.  */
 #define IS_TAILABLE_FILE_TYPE(Mode) \
-  (S_ISREG (Mode) || IS_PIPE_LIKE_FILE_TYPE (Mode) || S_ISCHR (Mode))
+  (S_ISREG (Mode) || S_ISFIFO (Mode) || S_ISSOCK (Mode) || S_ISCHR (Mode))
 
 static char const *const follow_mode_string[] =
 {
@@ -1640,14 +1636,14 @@ main (int argc, char **argv)
         device type, because device independence is an important
         principle of the system's design.
 
-        Follow the POSIX requirement only if POSIXLY_CORRECT is set.
-        Ideally this would ignore -f only for pipes, but S_ISFIFO
-        succeeds for both FIFOs and pipes and we know of no portable,
-        reliable way to distinguish them.  */
+        Follow the POSIX requirement only if POSIXLY_CORRECT is set.  */
+
       if (forever && getenv ("POSIXLY_CORRECT"))
        {
-         struct stat stats;
-         if (fstat (STDIN_FILENO, &stats) == 0 && S_ISFIFO (stats.st_mode))
+         int is_a_pipe = isapipe (STDIN_FILENO);
+         if (is_a_pipe < 0)
+           error (EXIT_FAILURE, errno, _("standard input"));
+         if (is_a_pipe)
            forever = false;
        }
     }