On Sat, Oct 08, 2005 at 03:56:05PM +0200, Jaap Eldering wrote: > > Here is a simple patch for an extra '--runtime=x' option.
Corrected some small errors in the patch of the man-page. Jaap
diff -urN tmpreaper-1.6.5/tmpreaper.8.in tmpreaper-1.6.5-runtime/tmpreaper.8.in
--- tmpreaper-1.6.5/tmpreaper.8.in 2003-12-08 12:53:27.000000000 +0100
+++ tmpreaper-1.6.5-runtime/tmpreaper.8.in 2005-10-09 11:28:36.125680328
+0200
@@ -8,7 +8,9 @@
[\-\-force]
[\-\-delay=x]
[\-\-atime] [\-\-mtime] [\-\-mtime-dir] [\-\-symlinks] [\-\-all]
-[[\-\-protect '<shell_pattern>']...] <time_spec> <dirs>...
+[[\-\-protect '<shell_pattern>']...]
+[\-\-runtime=x]
+<time_spec> <dirs>...
.SH DESCRIPTION
\fBtmpreaper\fR recursively searches for and removes files and empty
@@ -31,7 +33,7 @@
warning message, as attempts to keep it running long enough so that it
runs in parallel with another instance of itself may also lead to possible
vulnerabilities. Normally, \fBtmpreaper\fR won't need that amount of time.
-If your system is so slow that it does, please file a bug report...
+Use the \fB\-\-runtime\fR option if this default is not enough.
\fBtmpreaper\fR dates files by their \fIatime\fR, not their \fImtime\fR,
unless you select the \fB\-\-mtime\fR option. If files aren't being removed
@@ -145,6 +147,13 @@
'.X*\-{lock,unix{/*,}}' \-\-protect '.ICE\-{unix{/*,}}' \\
5d /tmp # 5 day grace period
+.TP
+\fB\-\-runtime=x\fR
+Abort \fBtmpreaper\fR after running for \fIx\fR seconds instead of the
+default 55 seconds. A value of 0 will disable this feature, which is
+not advised as this feature prevents possible race-conditions between
+different instances of \fBtmpreaper\fR.
+
.SH TIPS
As long as there are files present inside a subdirectory, it won't get
removed. You can use a non-writable, self-owned file, perhaps named
diff -urN tmpreaper-1.6.5/tmpreaper.c tmpreaper-1.6.5-runtime/tmpreaper.c
--- tmpreaper-1.6.5/tmpreaper.c 2003-12-08 12:39:36.000000000 +0100
+++ tmpreaper-1.6.5-runtime/tmpreaper.c 2005-10-09 11:03:55.766617800 +0200
@@ -170,8 +170,9 @@
#define LOG_ERROR 5
#define LOG_FATAL 6
-int logLevel = LOG_NORMAL;
-int delayMax = 0;
+int logLevel = LOG_NORMAL;
+int delayMax = 0;
+int runtimeMax = 55;
void
message (const int level,
@@ -686,6 +687,7 @@
{ "protect", required_argument, NULL, 'p' },
{ "delay", optional_argument, NULL, 'd' },
{ "showdeleted",no_argument, NULL, 'V' },
+ { "runtime", required_argument, NULL, 'r' },
{ 0, 0, 0, 0 }
};
@@ -759,9 +761,14 @@
message(LOG_DEBUG, "delay is %d seconds max\n", delayMax);
break;
- case 'V':
- flags |= FLAGS_SHOWDEL;
- break;
+ case 'V':
+ flags |= FLAGS_SHOWDEL;
+ break;
+
+ case 'r':
+ runtimeMax = atoi(optarg);
+ message(LOG_DEBUG, "runtime is %d seconds max\n", runtimeMax);
+ break;
}
}
@@ -881,7 +888,7 @@
}
signal(SIGALRM, sig_alarmhandler);
- alarm(55);
+ alarm(runtimeMax);
/* For each directory in the cleanup list, cd there, glob, then delete */
for (adir = optind; adir < argc; adir++) {
signature.asc
Description: Digital signature

