Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/libexec/lfs_cleanerd Pull up revision 1.17 (requested b...
details: https://anonhg.NetBSD.org/src/rev/51b687363630
branches: netbsd-1-4
changeset: 469873:51b687363630
user: he <he%NetBSD.org@localhost>
date: Thu Dec 16 23:50:11 1999 +0000
description:
Pull up revision 1.17 (requested by perseant):
If the cleaner is being respawned and dies repeatedly, avoid
looping.
diffstat:
libexec/lfs_cleanerd/cleanerd.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diffs (56 lines):
diff -r dad4a0dc7c5f -r 51b687363630 libexec/lfs_cleanerd/cleanerd.c
--- a/libexec/lfs_cleanerd/cleanerd.c Thu Dec 16 23:49:45 1999 +0000
+++ b/libexec/lfs_cleanerd/cleanerd.c Thu Dec 16 23:50:11 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cleanerd.c,v 1.13.2.2 1999/07/01 19:53:23 perry Exp $ */
+/* $NetBSD: cleanerd.c,v 1.13.2.3 1999/12/16 23:50:11 he Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)cleanerd.c 8.5 (Berkeley) 6/10/95";
#else
-__RCSID("$NetBSD: cleanerd.c,v 1.13.2.2 1999/07/01 19:53:23 perry Exp $");
+__RCSID("$NetBSD: cleanerd.c,v 1.13.2.3 1999/12/16 23:50:11 he Exp $");
#endif
#endif /* not lint */
@@ -176,6 +176,8 @@
int opt, cmd_err;
pid_t childpid;
char *fs_name; /* name of filesystem to clean */
+ time_t now, lasttime;
+ int loopcount;
cmd_err = debug = do_quit = 0;
clean_opts = 0;
@@ -236,13 +238,27 @@
if (debug == 0) {
if (daemon(0, 0) == -1)
err(1, "lfs_cleanerd: couldn't become a daemon!");
+ lasttime=0;
+ loopcount=0;
loop:
if((childpid=fork())<0) {
- syslog(LOG_NOTICE,"lfs_cleanerd: couldn't fork, exiting: %m");
+ syslog(LOG_NOTICE,"%s: couldn't fork, exiting: %m",
+ fs_name);
exit(1);
}
if(childpid != 0) {
wait(NULL);
+ /* If the child is looping, give up */
+ ++loopcount;
+ if((now=time(NULL)) - lasttime > TIME_THRESHOLD) {
+ loopcount=0;
+ }
+ lasttime = now;
+ if(loopcount > LOOP_THRESHOLD) {
+ syslog(LOG_ERR,"%s: cleanerd looping, exiting",
+ fs_name);
+ exit(1);
+ }
if (fs_getmntinfo(&lstatfsp, fs_name, MOUNT_LFS) == 0) {
/* fs has been unmounted(?); exit quietly */
syslog(LOG_INFO,"lfs_cleanerd: fs %s unmounted, exiting", fs_name);
Home |
Main Index |
Thread Index |
Old Index