]> mj.ucw.cz Git - eval.git/blobdiff - box/box.c
Added a description of the meta-files
[eval.git] / box / box.c
index b77ec8d66387d97c48a2f8da72940a16997c2fc9..323e07e77e9d270dc85d43f0092a346deba41ed1 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;
@@ -116,6 +117,7 @@ box_exit(int rc)
        ptrace(PTRACE_KILL, box_pid);
       kill(-box_pid, SIGKILL);
       kill(box_pid, SIGKILL);
+      meta_printf("killed:1\n");
 
       struct rusage rus;
       int stat;
@@ -771,7 +773,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 +1076,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 +1088,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 +1142,9 @@ main(int argc, char **argv)
       case 'w':
         wall_timeout = 1000*atof(optarg);
        break;
+      case 'x':
+       extra_timeout = 1000*atof(optarg);
+       break;
       default:
        usage();
       }