mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-09-07 03:07:02 -04:00
119 lines
3.0 KiB
Plaintext
119 lines
3.0 KiB
Plaintext
$NetBSD: patch-aa,v 1.1 2002/07/04 13:32:21 agc Exp $
|
|
|
|
Add a test to see if the log file has been turned over, and to re-open
|
|
files if it has.
|
|
|
|
--- root-tail.c 2002/07/04 13:05:32 1.1
|
|
+++ root-tail.c 2002/07/04 13:18:38
|
|
@@ -27,14 +27,6 @@
|
|
|
|
#define VERSION "0.0.10"
|
|
|
|
-/*---------------- Let's define signals functions -------------*/
|
|
-
|
|
-static void reopen (int);
|
|
-static void list_files (int);
|
|
-static void force_refresh (int);
|
|
-static void InstallSigHandler (void);
|
|
-FILE *openLog (const char *);
|
|
-
|
|
/*------------------------ initalize variables -----------------*/
|
|
int geom_mask, noinitial;
|
|
int screen, listlen = STD_HEIGHT, width = STD_WIDTH, ScreenWidth, ScreenHeight,
|
|
@@ -58,6 +50,7 @@
|
|
char desc[255]; /* alternative description */
|
|
FILE *f; /* FILE struct associated with file */
|
|
Pixel color; /* color to be used for printing */
|
|
+ struct stat st; /* stat buffer from previous */
|
|
struct logfile_entry *next;
|
|
};
|
|
|
|
@@ -70,6 +63,14 @@
|
|
Pixel color;
|
|
};
|
|
|
|
+/*---------------- Let's define signals functions -------------*/
|
|
+
|
|
+static void reopen (int);
|
|
+static void list_files (int);
|
|
+static void force_refresh (int);
|
|
+static void InstallSigHandler (void);
|
|
+FILE *openLog (struct logfile_entry *, const char *);
|
|
+
|
|
|
|
/*----------------------------- start code ---------------------*/
|
|
|
|
@@ -83,7 +84,7 @@
|
|
{
|
|
printf ("reopenin as %p (%s)\n", e->f, e->fname);
|
|
fclose (e->f);
|
|
- e->f = openLog (e->fname);
|
|
+ e->f = openLog (e, e->fname);
|
|
printf ("reopened as %p\n", e->f);
|
|
if (e->f == NULL)
|
|
{
|
|
@@ -226,15 +227,15 @@
|
|
}
|
|
|
|
FILE *
|
|
-openLog (const char *name)
|
|
+openLog (struct logfile_entry *e, const char *name)
|
|
{
|
|
FILE *f = fopen (name, "r");
|
|
- struct stat statbuf;
|
|
off_t size;
|
|
+
|
|
if (f == NULL)
|
|
return NULL;
|
|
- stat (name, &statbuf);
|
|
- size = statbuf.st_size;
|
|
+ stat (name, &e->st);
|
|
+ size = e->st.st_size;
|
|
if (size > (listlen+1) * width)
|
|
{
|
|
char dummy[255];
|
|
@@ -363,8 +364,16 @@
|
|
|
|
for (current = loglist; current != NULL; current = current->next)
|
|
{
|
|
+ struct stat st;
|
|
clearerr (current->f);
|
|
|
|
+ if (stat(current->fname, &st) < 0) {
|
|
+ continue;
|
|
+ }
|
|
+ if (st.st_ino != current->st.st_ino) {
|
|
+ need_reopen = 1;
|
|
+ }
|
|
+
|
|
while (!lineinput (temp, width + 2, current->f))
|
|
{
|
|
/*
|
|
@@ -418,7 +427,7 @@
|
|
if (need_reopen)
|
|
reopen (1);
|
|
|
|
- /* we ignore possible errors due to windo resizing &c */
|
|
+ /* we ignore possible errors due to window resizing &c */
|
|
while (XPending (disp))
|
|
{
|
|
XNextEvent (disp, &xev);
|
|
@@ -607,13 +616,14 @@
|
|
}
|
|
}
|
|
|
|
- if ((f = openLog (fname)) == NULL)
|
|
+ e = (struct logfile_entry *)
|
|
+ malloc (sizeof (struct logfile_entry));
|
|
+
|
|
+ if ((f = openLog (e, fname)) == NULL)
|
|
{
|
|
perror (fname);
|
|
exit (-1);
|
|
}
|
|
- e = (struct logfile_entry *)
|
|
- malloc (sizeof (struct logfile_entry));
|
|
|
|
strncpy (e->fname, fname, 255);
|
|
e->fname[255] = '\0'; /* just in case */
|