]> mj.ucw.cz Git - eval.git/commitdiff
Box: Implemented the `-x' (extra timeout) option
authorMartin Mares <mj@ucw.cz>
Sun, 5 Apr 2009 16:48:17 +0000 (18:48 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 5 Apr 2009 16:48:17 +0000 (18:48 +0200)
box/box.c

index b77ec8d66387d97c48a2f8da72940a16997c2fc9..c93ed0d41e71182cc4a132c93c55e89e10075495 100644 (file)
--- a/box/box.c
+++ b/box/box.c
@@ -32,6 +32,7 @@
 static int filter_syscalls;            /* 0=off, 1=liberal, 2=totalitarian */
 static int timeout;                    /* milliseconds */
 static int wall_timeout;
+static int extra_timeout;
 static int pass_environ;
 static int file_access;
 static int verbose;
@@ -771,7 +772,7 @@ check_timeout(void)
       ms = (utime + stime) * 1000 / ticks_per_sec;
       if (verbose > 1)
        fprintf(stderr, "[time check: %d msec]\n", ms);
-      if (ms > timeout)
+      if (ms > timeout && ms > extra_timeout)
        err("TO: Time limit exceeded");
     }
 }
@@ -1074,6 +1075,8 @@ Options:\n\
 -T\t\tAllow syscalls for measuring run time\n\
 -v\t\tBe verbose (use multiple times for even more verbosity)\n\
 -w <time>\tSet wall clock time limit (seconds, fractions allowed)\n\
+-x <time>\tSet extra timeout, before which a timing-out program is not yet killed,\n\
+\t\tso that its real execution time is reported (seconds, fractions allowed)\n\
 ");
   exit(2);
 }
@@ -1084,7 +1087,7 @@ main(int argc, char **argv)
   int c;
   uid_t uid;
 
-  while ((c = getopt(argc, argv, "a:c:eE:fi:m:M:o:p:r:s:t:Tvw:")) >= 0)
+  while ((c = getopt(argc, argv, "a:c:eE:fi:m:M:o:p:r:s:t:Tvw:x:")) >= 0)
     switch (c)
       {
       case 'a':
@@ -1138,6 +1141,9 @@ main(int argc, char **argv)
       case 'w':
         wall_timeout = 1000*atof(optarg);
        break;
+      case 'x':
+       extra_timeout = 1000*atof(optarg);
+       break;
       default:
        usage();
       }