Hi,

Here is a simple patch for an extra '--runtime=x' option.

Kind regards,
Jaap Eldering
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-08 15:25:37.462342982 
+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
@@ -131,6 +133,13 @@
 than once.  It has no one letter abbreviation, you must spell out the
 full word "protect".
 
+.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.
+
 If you do not enclose the \fI<shell_pattern>\fR in single quotes, the
 shell will perform the expansion before \fBtmpreaper\fR reads its
 argument array.  The program does not support that syntax, so you
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-08 15:31:44.039661402 +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++) {

Attachment: signature.asc
Description: Digital signature

Reply via email to