bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improved tail patch


From: Paul Eggert
Subject: Re: Improved tail patch
Date: Wed, 21 Jul 2004 21:50:32 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

address@hidden writes:

> Moving tail to use select won't help for fifo's I'm afraid. I think it
> would also make keeping track of rotations and such messier, but I'm not
> sure.

I think the rotation stuff would be about as messy as it is now.  :-)
But admittedly I haven't looked into it.


> Select always returns ready for a fifo.

No, when you're reading from a fifo, 'select' returns ready only when
there is actual data to read.  At least, that's what POSIX says, and
I just tested the following program and it works that way.

        #include <stdio.h>
        #include <sys/time.h>
        #include <sys/types.h>
        #include <unistd.h>

        int
        main (void)
        {
          fd_set infds;
          int n;
          char buf[1];

          FD_ZERO (&infds);
          FD_SET (0, &infds);
          n = select (1, &infds, NULL, NULL, NULL);
          if (n < 0)
            {
              perror ("select");
              return 1;
            }
          return 0;
        }

Here's a transcript:

        $ mkfifo fifo
        $ (sleep 10; echo foo) >fifo &  (date; ./a.out; date; cat) <fifo
        [1] 17105
        Wed Jul 21 21:47:32 PDT 2004
        Wed Jul 21 21:47:42 PDT 2004
        foo
        [1]+  Done                    ( sleep 10; echo foo ) >fifo
        $ 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]