On Tue, Dec 16, 2008 at 01:35:53AM -0500, Stefan Karpinski wrote: > > On Mon, Dec 15, 2008 at 7:56 PM, Jeff King <peff@xxxxxxxx> wrote: > > 2. detect EOF before starting the pager. We in fact already delay > > running the pager in the forked process until we have some activity > > on the pipe, but I don't know if there is a portable way of > > detecting that that activity is EOF without performing an actual > > read() call (which is undesirable, since it eats the first byte of > > output that should go to the pager). > > Wouldn't ungetc work? Or is that not portable enough? (It would only > work here because the EOF has to be the first character.) No, it won't work. ungetc works on the buffered stdio object, so it is useful for pushing back characters onto the buffer to be read later in the program from the same buffer. But in this case, we are going to execv() (or on Windows, spawn) the pager, meaning it will throw away anything that has been read() from the pipe and put in the buffer. So we would need a system call to push a character back to the OS, so that it was available for read() by the pager process. -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html