Sapan, Welcome to the list! And here begins the nitpicking...
tail does what it does as it cannot assume anything about the source of the generated file - can be logging process or some app or even a special device file. Regarding the logging process writing to psuedo master, as per my other post, syslog already does that - let's you write to named pipes et al. Now, an interesting question is that is this more efficient, i.e. reading/writing to/from named pipe/pty rather than fstat'ing the file - don't both of them incur the same penalty in terms of system calls? You say that fstat would have to access the disk? This is something that I am not sure about - when does Linux serialize changed filesyste info to disk? Are there chances that when I do two consecutive fstat's "quickly" I might get data from in memory? What about the pty device? What if that memory gets swapped to disk? What can we say about the chances for the above two incidents to happen statistically. No flamewars please, I'm just nitpicking ;) Regards, -Varun On Fri, Mar 29, 2002 at 11:46:37PM +0530, Sapan J . Bhatia spoke out thus: > (First post) > > Hi, > > Doing an strace on tail -f <file> reveals that it does an fstat every > 1 second (fstat, nanosleep 1, fstat nanosleep 1...) for the file size and > reads and writes to stdout whenever the value of st_size returned changes. > > A better way of doing this IMHO would be for the logging process to write to > a pty master device and for the reading process to pick it up from the > slave. Tht way you can use async IO (SIGIO / sigaction(2)) or a blocking > POLL on the pts device. > > Sapan > > > On Fri, Mar 29, 2002 at 07:06:44PM +0530, Manish K Arya wrote: > // Hi > // how can i read logs dynamically in C. like if i do tail -f <logfile> output >goes to stdout.i want same kind of mechenism to read log files in C. > // > // bye > // --- > // Manish Kumar Arya > // > // > // > // See Dave Matthews Band live or win a signed guitar > // >http://r.lycos.com/r/bmgfly_mail_dmb/http://win.ipromotions.com/lycos_020201/splash.asp > > // > // ================================================ > // To subscribe, send email to [EMAIL PROTECTED] with subscribe in subject >header > // To unsubscribe, send email to [EMAIL PROTECTED] with unsubscribe in subject >header > // Archives are available at http://www.mail-archive.com/ilugd%40wpaa.org > // ================================================= > // > > ----- End forwarded message ----- > > ================================================ > To subscribe, send email to [EMAIL PROTECTED] with subscribe in subject header > To unsubscribe, send email to [EMAIL PROTECTED] with unsubscribe in subject >header > Archives are available at http://www.mail-archive.com/ilugd%40wpaa.org > ================================================= -- -------------------------------------- Mindframe Software & Service Pvt. Ltd. http://www.mindsw.com -------------------------------------- ================================================ To subscribe, send email to [EMAIL PROTECTED] with subscribe in subject header To unsubscribe, send email to [EMAIL PROTECTED] with unsubscribe in subject header Archives are available at http://www.mail-archive.com/ilugd%40wpaa.org =================================================