On Wed, Sep 11, 2002, Muli Ben-Yehuda wrote about "Re: tail(1) and char device files": > No, that's not it. For !S_ISREG files, tail does the equivalent of: > > while (read(...) > 0) { > allocate a buffer > add what we read to the buffer > continue > } > > That loop will only terminate when tail runs out of memory (there's an > xmalloc() inside the loop) or when read returns 0 (EOF) or -1 (error), > and then tail will print everything.
Why everything? It should only print the last 10 lines (by default)... Does it really save *the entire input* in memory, without any attempt to "forget" all lines that are not the last 10? > Yup, as is our character device. I'll see if I can find any mentions > of this behaviour from tail in POSIX. Because "tail -f" is supposed to print the last 10 lines *and* then continue to show everything else, what exactly "tail -f" does on a file that cannot be reopened is indeed a good question... I suppose that your suggestion (to have it be equivalent to "cat") might be more useful than the current behavior (equivalent to "tail" without -f), but maybe something is explicitly defined in the standard? POSIX (or SUv3) is available online freely, by the way, so you might want to have a look. -- Nadav Har'El | Wednesday, Sep 11 2002, 6 Tishri 5763 [EMAIL PROTECTED] |----------------------------------------- Phone: +972-53-245868, ICQ 13349191 |Ms Piggy's last words: "I'm pink, http://nadav.harel.org.il |therefore I'm ham." ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]