summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2004-06-07 21:09:58 +0000
committergad <gad@FreeBSD.org>2004-06-07 21:09:58 +0000
commit717539c68068661ebd0d828db4a5585753bcba9f (patch)
treec5775c4b910cf1d7e620d527930b3c2f75eb42a0 /usr.sbin
parentbfb13da83136c5d9301591fe777eef0d80120494 (diff)
downloadFreeBSD-src-717539c68068661ebd0d828db4a5585753bcba9f.zip
FreeBSD-src-717539c68068661ebd0d828db4a5585753bcba9f.tar.gz
In "neworder" processing, reduce the delay between signals to separate
processes, and balance that by adding a 10-second delay after all the processes have been signaled. Also improvement a few messages printed with `-n' or `-v' processing (mostly signal-related messages). MFC after: 13 days
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/newsyslog/newsyslog.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index 7c80c96..ab3cad4 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -278,10 +278,18 @@ main(int argc, char **argv)
* sigwork_entry's, so we can not free the entries here.
*/
if (!SLIST_EMPTY(&swhead)) {
- if (noaction)
+ if (noaction || verbose)
printf("Signal all daemon process(es)...\n");
SLIST_FOREACH(stmp, &swhead, sw_nextp)
do_sigwork(stmp);
+ if (noaction)
+ printf("\tsleep 10\n");
+ else {
+ if (verbose)
+ printf("Pause 10 seconds to allow daemon(s)"
+ " to close log file(s)\n");
+ sleep(10);
+ }
}
/*
* Compress all files that we're expected to compress, now
@@ -289,7 +297,7 @@ main(int argc, char **argv)
* have been rotated.
*/
if (!SLIST_EMPTY(&zwhead)) {
- if (noaction)
+ if (noaction || verbose)
printf("Compress all rotated log file(s)...\n");
while (!SLIST_EMPTY(&zwhead)) {
ztmp = SLIST_FIRST(&zwhead);
@@ -1658,7 +1666,8 @@ do_rotate(const struct conf_entry *ent)
static void
do_sigwork(struct sigwork_entry *swork)
{
- int kres;
+ struct sigwork_entry *nextsig;
+ int kres, secs;
if (!(swork->sw_pidok) || swork->sw_pid == 0)
return; /* no work to do... */
@@ -1679,9 +1688,25 @@ do_sigwork(struct sigwork_entry *swork)
return;
}
+ /*
+ * Compute the pause between consecutive signals. Use a longer
+ * sleep time if we will be sending two signals to the same
+ * deamon or process-group.
+ */
+ secs = 0;
+ nextsig = SLIST_NEXT(swork, sw_nextp);
+ if (nextsig != NULL) {
+ if (swork->sw_pid == nextsig->sw_pid)
+ secs = 10;
+ else
+ secs = 1;
+ }
+
if (noaction) {
- printf("\tkill -%d %d\n", swork->sw_signum, (int)swork->sw_pid);
- printf("\tsleep 10\n");
+ printf("\tkill -%d %d \t\t# %s\n", swork->sw_signum,
+ (int)swork->sw_pid, swork->sw_fname);
+ if (secs > 0)
+ printf("\tsleep %d\n", secs);
return;
}
@@ -1699,12 +1724,15 @@ do_sigwork(struct sigwork_entry *swork)
warn("can't notify %s, pid %d", swork->sw_pidtype,
(int)swork->sw_pid);
} else {
- if (verbose) {
- printf("%s pid %d notified\n", swork->sw_pidtype,
- (int)swork->sw_pid);
- printf("pause to allow daemon(s) to close log(s)\n");
+ if (verbose)
+ printf("Notified %s pid %d = %s\n", swork->sw_pidtype,
+ (int)swork->sw_pid, swork->sw_fname);
+ if (secs > 0) {
+ if (verbose)
+ printf("Pause %d second(s) between signals\n",
+ secs);
+ sleep(secs);
}
- sleep(10);
}
}
OpenPOWER on IntegriCloud