FreeBSD Bugzilla – Attachment 13109 Details for
Bug 25070
newsyslog(8) should send signals only once per run
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 3.62 KB, created by
newsyslog
on 2001-02-13 20:10:02 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
newsyslog
Created:
2001-02-13 20:10:02 UTC
Size:
3.62 KB
patch
obsolete
>--- newsyslog.c.ORIG Fri Oct 20 13:27:03 2000 >+++ newsyslog.c Mon Feb 12 06:51:39 2001 >@@ -81,6 +81,22 @@ > struct conf_entry *next;/* Linked list pointer */ > }; > >+struct log_entry { >+ char *log; /* name of the log to be compressed */ >+ struct log_entry* next; /* Linked list pointer */ >+}; >+ >+struct kill_entry { >+ pid_t pid; /* PID to kill */ >+ int sig; /* Signal to send */ >+ struct kill_entry* next;/* Linked list pointer */ >+}; >+ >+struct kill_entry* kill_pending = NULL; >+ /* List of PIDs to be killed */ >+struct log_entry* log_pending = NULL; >+ /* List of logs to be compressed */ >+ > int archtodir = 0; /* Archive old logfiles to other directory */ > int verbose = 0; /* Print out what's going on */ > int needroot = 1; /* Root privs are necessary */ >@@ -99,6 +115,8 @@ > static char *sob(char *p); > static char *son(char *p); > static char *missing_field(char *p, char *errline); >+static int save_kill(pid_t pid, int sig); >+static void save_compress_log(char* file); > static void do_entry(struct conf_entry * ent); > static void PRS(int argc, char **argv); > static void usage(); >@@ -117,6 +135,9 @@ > main(int argc, char **argv) > { > struct conf_entry *p, *q; >+ struct kill_entry* k; >+ struct log_entry* l; >+ int notified; > > PRS(argc, argv); > if (needroot && getuid() && geteuid()) >@@ -129,6 +150,34 @@ > free((char *) q); > q = p; > } >+ >+ notified = 0; >+ while (kill_pending) { >+ if (kill(kill_pending->pid, kill_pending->sig)) >+ warn("can't notify daemon, pid %d", (int) kill_pending->pid); >+ else { >+ notified = 1; >+ if (verbose) >+ printf("daemon pid %d notified\n", (int) kill_pending->pid); >+ } >+ k = kill_pending; >+ kill_pending = kill_pending->next; >+ free((char *) k); >+ } >+ if (notified) { >+ if (verbose) >+ printf("small pause to allow daemons to close logs\n"); >+ sleep(10); >+ } >+ >+ while (log_pending) { >+ compress_log(log_pending->log); >+ free(log_pending->log); >+ l = log_pending; >+ log_pending = log_pending->next; >+ free((char *) l); >+ } >+ > return (0); > } > >@@ -470,6 +519,38 @@ > return (p); > } > >+static int >+save_kill(pid_t pid, int sig) >+{ >+ struct kill_entry* p; >+ >+ for (p = kill_pending; p != NULL; p = p->next) >+ if (p->pid == pid && p->sig == sig) >+ return (0); >+ >+ p = (struct kill_entry *) malloc(sizeof(struct kill_entry)); >+ p->pid = pid; >+ p->sig = sig; >+ p->next = kill_pending; >+ kill_pending = p; >+ return (0); >+} >+ >+static void >+save_compress_log(char *file) >+{ >+ struct log_entry* p; >+ >+ for (p = log_pending; p != NULL; p = p->next) >+ if (!strcmp(p->log, file)) >+ return; >+ >+ p = (struct log_entry *) malloc(sizeof(struct log_entry)); >+ p->log = strdup(file); >+ p->next = log_pending; >+ log_pending = p; >+} >+ > static void > dotrim(char *log, char *pid_file, int numdays, int flags, int perm, > int owner_uid, int group_gid, int sig) >@@ -613,12 +694,12 @@ > if (noaction) { > notified = 1; > printf("kill -%d %d\n", sig, (int) pid); >- } else if (kill(pid, sig)) >+ } else if (save_kill(pid, sig)) > warn("can't notify daemon, pid %d", (int) pid); > else { > notified = 1; > if (verbose) >- printf("daemon pid %d notified\n", (int) pid); >+ printf("will notify daemon pid %d\n", (int) pid); > } > } > if ((flags & CE_COMPACT)) { >@@ -627,16 +708,11 @@ > else if (noaction) > printf("Compress %s.0\n", log); > else { >- if (notified) { >- if (verbose) >- printf("small pause to allow daemon to close log\n"); >- sleep(10); >- } > if (archtodir) { > (void) sprintf(file1, "%s/%s", dirpart, namepart); >- compress_log(file1); >+ (pid == 0 ? compress_log : save_compress_log)(file1); > } else { >- compress_log(log); >+ (pid == 0 ? compress_log : save_compress_log)(log); > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 25070
: 13109